How to Bootstrap- Responsive Table
In this guide, we are going to learn how to render Bootstrap responsive table with the help of predefined Bootstrap classes. The Bootstrap gives you the greate looking table in a simple way. Let’s dive into Bootstrap table codes.
You can create tables with normal HTML tags, Bootstrap will automatically adjust the cell padding and other predefined styles, by adding .table
class to the <table>
element. Let’s create a simple table with .table
class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<table class="table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Anwar Yakkiparamban</td> </tr> <tr> <td>2</td> <td>Habeeb Yakkiparamban</td> </tr> <tr> <td>3</td> <td>Muhsin Yakkiparamban</td> </tr> </tbody> </table> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |
Bootstrap Table with Striped Row
You can create a table with stripes on the row by adding the table-striped
class, The following example shows you the demonstration.
1 2 3 4 5 6 7 8 |
<!--Striped table example--> <table class="table table-striped"> </table> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |
Bootstrap Bordered Table
You can create a table with the border on each cell by adding the table-bordered
class, The following example shows you the demonstration.
1 2 3 4 5 6 7 8 |
<!--Bordered table example--> <table class="table table-bordered"> </table> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |
Bootstrap Hover Tables
You can create a table with hover enabled on rows cell by adding the table-hover
class, The following example shows you the demonstration.
1 2 3 4 5 6 7 8 |
<!--Hover table example--> <table class="table table-hover"> </table> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |
Bootstrap Condensed Table
You can also create a table with lower cell padding for condensation by adding the table-condensed
class, Let’s see the example of condensed table.
1 2 3 4 5 6 7 8 |
<!--Hover table example--> <table class="table table-condensed"> </table> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |
Bootstrap Responsive Table
You can create responsive tables with Bootstrap 3. To make a table responsive, place the table inside a <div>
tag with class table-responsive
. With responsive table, you can make the table scroll horizontally up to small devices with screen size under 768px. When viewing on larger devices, you can’t see any difference in the table. Let’s see the example of a responsive table.
1 2 3 4 5 6 7 8 9 10 |
<!--Hover table example--> <div class="table-responsive"> <table class="table table-bordered"> </table> </div> |
ID | Name | |
---|---|---|
1 | Anwar Yakkiparamban | [email protected] |
2 | Habeeb Yakkiparamban | [email protected] |
3 | Muhsin Yakkiparamban | [email protected] |