Cara Membuat Layout di bootstrap

Desember 21, 2016 0 Comments

Baiklah kita kali ini akan membuat layout web dengan menggunakan bootstrap, bootstrap merupakan framework css yang paling banyak digunakan saat ini karena tampilanya yang sangat menarik. bootstrap pertama kali diperkenalkan pada tahun 2011 oleh Mark Otto untuk twitter. framework ini menggabungkan html, css dan javascript jadi anda tidak usah ribet lagi mengatur css dan javascriptnya cukup dengan html dengan memanfaatkan class yang ada anda sudah bisa membuat website. jika anda belum mempunyai file bootstrapnya silakan di download di getbootstrap.com secara gratis. jika sudah anda download silakan anda ekstrak.
Pada layout yang akan kita buat ini kita akan mennggunakan navbar untuk menu navigasi kemudian carousel untuk slidernya, lalu dibawahnya ada jumbotron dan di bawahnya ada tiga buah grid. lalu di halaman profile ada paragraf untuk menampilkan post dan dibawahnya ada paination, dan disebelah kanan menu ada tombol login jika di klik akan menampilkan modal login.
Untuk membuatnya pertama buat file index.php isinya seperti berikut:

<!DOCTYPE html>
<html>
    <head>
        <title>Latihan form</title>
        <!-- Bootstrap Core CSS -->
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <!-- Bootstrap Core JS -->
<script src="bootstrap/js/jquery.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
    </head>
    <body>


<nav class="navbar navbar-default">
 <div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
 </button>
 <a class="navbar-brand" href="index.html">BRAND</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
 <ul class="nav navbar-nav">
<li class="active"><a href="index.html">Beranda <span class="sr-only">(current)</span></a></li>
<li><a href="profile.html">Profile</a></li>
<li class="dropdown">
 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Category <span class="caret"></span></a>
 <ul class="dropdown-menu">
<li><a href="category-olahraga.html">Olahraga</a></li>
<li><a href="category-gosip.html">Gosip</a></li>
<li><a href="category-politik.html">Politik</a></li>
 </ul>
</li>
 </ul>
 <form class="navbar-form navbar-left" role="search">
<div class="form-group">
 <input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
 </form>
 <ul class="nav navbar-nav navbar-right">
<li><a href="register.html">Register</a></li>
<li><a class="btn" data-toggle="modal" data-target="#myModal">Login</a></li>
 </ul>
</div><!-- /.navbar-collapse -->
 </div><!-- /.container-fluid -->
</nav>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
 <div class="modal-dialog" role="document">
<div class="modal-content">
 <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
 </div>
 <div class="modal-body">
<input type="text" name="username" class="form-control" placeholder="Username"><br>
<input type="password" name="password" class="form-control" placeholder="Password">
 </div>
 <div class="modal-footer">
<input type="checkbox" name="check" class="left">Ingat Saya
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success">Login</button>
 </div>
</div>
 </div>
</div>


<!-- Page Content -->
<div class="container">

<!-- Heading Row -->
<div class="row">
<div class="col-md-12">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
 <!-- Indicators -->
 <ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
 </ol>

 <!-- Wrapper for slides -->
 <div class="carousel-inner" role="listbox">
<div class="item active">
 <img src="image/1d.jpg" alt="...">
 <div class="carousel-caption">
<h3>First Thumbnail Label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
 </div>
</div>
<div class="item">
 <img src="image/2c.jpg" alt="...">
 <div class="carousel-caption">
<h3>Second Thumbnail label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
 </div>
</div>
<div class="item">
 <img src="image/3c.jpeg" alt="...">
 <div class="carousel-caption">
<h3>Third Thumbnail Label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
 </div>
</div>
 </div>

 <!-- Controls -->
 <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
 </a>
 <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
 </a>
</div>
</div>
</div>
<!-- /.row -->

<div class="row">
<div class="col-md-12">
<!-- Hello Word yang nyambung-->
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur.</p>
<a class="btn btn-default" href="#">More Info</a>
</div>
<!-- /.col-md-4 -->
<!-- Content Row -->
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="image/2c.jpg" alt="Gambar 1">
<div class="caption">
<h3>Thumbnail label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>

<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="image/2c.jpg" alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>

<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="image/2c.jpg" alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>

</div>
<!-- /.col-md-4 -->
</div>
<!-- /.row -->

<!-- Footer -->

<footer style="margin-top:20px;">
<div class="row">
<div class="col-lg-12">
<p>Copyright &copy; MY Website 2016</p>
</div>
</div>
</footer>

</div>

    </body>
</html>

kemudian untuk file profile.php isinya seperti berikut:

<!DOCTYPE html>
<html>
    <head>
        <title>Latihan form</title>
        <!-- Bootstrap Core CSS -->
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <!-- Bootstrap Core JS -->
<script src="bootstrap/js/jquery.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
    </head>
    <body>


<nav class="navbar navbar-default">
 <div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
 </button>
 <a class="navbar-brand" href="index.html">BRAND</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
 <ul class="nav navbar-nav">
<li><a href="index.html">Beranda <span class="sr-only">(current)</span></a></li>
<li class="active"><a href="profile.html">Profile</a></li>
<li class="dropdown">
 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Category <span class="caret"></span></a>
 <ul class="dropdown-menu">
<li><a href="category-olahraga.html">Olahraga</a></li>
<li><a href="category-gosip.html">Gosip</a></li>
<li><a href="category-politik.html">Politik</a></li>
 </ul>
</li>
 </ul>
 <form class="navbar-form navbar-left" role="search">
<div class="form-group">
 <input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
 </form>
 <ul class="nav navbar-nav navbar-right">
<li><a href="register.html">Register</a></li>
<li><a class="btn" data-toggle="modal" data-target="#myModal">Login</a></li>
 </ul>
</div><!-- /.navbar-collapse -->
 </div><!-- /.container-fluid -->
</nav>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        <input type="text" name="username" class="form-control" placeholder="Username"><br>
<input type="password" name="password" class="form-control" placeholder="Password">
      </div>
      <div class="modal-footer">
<input type="checkbox" name="check" class="left">Ingat Saya
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-success">Login</button>
      </div>
    </div>
  </div>
</div>


<!-- Page Content -->
<div class="container">

<!-- Heading Row -->
<div class="row">
<div class="col-md-12">
<h3><a href="detail_news.html">Thumbnail label</a></h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
<h3><a href="detail_news.html">Thumbnail label</a></h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>
<h3><a href="detail_news.html">Thumbnail label</a></h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe rem nisi accusamus error velit animi non ipsa placeat. Recusandae, suscipit, soluta quibusdam accusamus a veniam quaerat eveniet eligendi dolor consectetur</p>

<nav>
  <ul class="pagination">
    <li><a href="#" aria-label="Previous"><span aria-hidden="true">Prev</span></a></li>
    <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
    <li><a href="#">2 <span class="sr-only"></span></a></li>
<li><a href="#">3 <span class="sr-only"></span></a></li>
<li><a href="#">4 <span class="sr-only"></span></a></li>
<li><a href="#">5 <span class="sr-only"></span></a></li>
<li><a href="#" aria-label="Previous"><span aria-hidden="true">Next</span></a></li>
  </ul>
</nav>
</div>
<!-- Footer -->

<footer style="margin-top:20px;">
<div class="row">
<div class="col-lg-12">
<p>Copyright &copy; MY Website 2016</p>
</div>
</div>
</footer>

</div>

    </body>
</html>

agar javascripnya jalan kita memerlukan library jquery silkan download file jquerynya di api.jquery.org/download untuk versinya kita gunakan yang versi 1.11.1 kemudian simpan file jquerynya di folder js.

sekianlah tutorial yang saya berikan semoga bermanfaat jika ada yang kurang di mengerti silakan ditanyakan di bawah terimakasih.

Juanas Smith Shared

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.

0 komentar :