Lengkap! Cara Membuat Tabel di Bootstrap
- Tabel Sederhana
Membuat tabel sederhana di boostrap menggunakan kode pemanggilan .table
Contoh source code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 0;
border-radius: 0;
}
/* Add a gray background color and some padding to the footer */
footer {
background-color: #f2f2f2;
padding: 25px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Portfolio</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="container text-center">
<h1>My Portfolio</h1>
<p>Some text that represents "Me"...</p>
</div>
</div>
<div class="container-fluid bg-3 text-center">
<h3>Some of my Work</h3><br>
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
</div><br>
<div class="container-fluid bg-3 text-center">
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
</div><br><br>
<footer class="container-fluid text-center">
<p>Footer Text</p>
</footer>
</body>
</html>
Hasil:
- Tabel baris yang bergaris
Nah untuk membuat tabel yang garisnya bergaris menggunakan kode pemanggilan .table-bordered
Contoh source code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Bordered Table</h2>
<p>The .table-bordered class adds borders to a table:</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Hasil:
- Tabel Warna-Warni
Konsep class tabel yang digunakan adalah table rows (<tr>) dan table cells (<tb>).
Contoh source code:
<!DOCTYPE html><html lang="en"><head><title>Bootstrap Example</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script></head><body><div class="container"><h2>Contextual Classes</h2><p>Contextual classes can be used to color table rows or table cells. The classes that can be used are: .active, .success, .info, .warning, and .danger.</p><table class="table"><thead><tr><th>Firstname</th><th>Lastname</th><th>Email</th></tr></thead><tbody><tr><td>Default</td><td>Defaultson</td><td>def@somemail.com</td></tr><tr class="success"><td>Success</td><td>Doe</td><td>john@example.com</td></tr><tr class="danger"><td>Danger</td><td>Moe</td><td>mary@example.com</td></tr><tr class="info"><td>Info</td><td>Dooley</td><td>july@example.com</td></tr><tr class="warning"><td>Warning</td><td>Refs</td><td>bo@example.com</td></tr><tr class="active"><td>Active</td><td>Activeson</td><td>act@example.com</td></tr></tbody></table></div></body></html>
Hasil:
Komentar
Posting Komentar