Whenever you need the large data to represent in statistic form than tables are the best way to represent them. Bootstrap provides complete default classes for tables in all possible manner with specific CSS classes for multiple use. Here we have compiled general info on Bootstrap table with suitable examples:
They follow the structure of HTML tags only but with specific bootstrap class. It depends on how you want to let the user view your table with more appeal and better he or she can understand the point.
Here we have precisely shortlisted some of the key CSS attributes for Bootstrap Table.
//Default Table CSS .table{width:100%;max-width:100%;margin-bottom:20px;} table{background-color:transparent;} table{border-spacing:0;border-collapse:collapse;} thead{display:table-header-group} .table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd;} .table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table > tbody > tr > td,.table > tfoot > tr > td { padding:8px;line-height: 1.42857143; vertical-align: top; border-top: 1px solid #ddd;}
Below given html structure is the default structure for Bootstrap table.
<div class="container"> <table class="table"> <thead><tr><th>Row</th><th>Table Type</th><th>Specific CSS Class</th><th>Try it Editor</th></tr></thead> <tbody> <tr><td>1</td><td>Striped rows</td><td>.table-striped</td><td>Try it now</td></tr> <tr><td>2</td><td>Bordered table</td><td>.table-bordered</td><td>Try it now</td></tr> <tr><td>3</td><td>Table with hover rows</td><td>.table-hover</td><td>Try it now</td></tr> <tr><td>4</td><td>Condensed table</td><td>.table-condensed</td><td>Try it now</td></tr> <tr><td>5</td><td>Responsive tables</td><td>.table-responsive</td><td>Try it now</td></tr> </tbody> </table> </div>
Check out these basic set of table styles that are provided with bootstrap.
Row | Table Type | Specific CSS Class | Try it Editor |
---|---|---|---|
1 | Striped rows | .table-striped | Try it now |
2 | Bordered table | .table-bordered | Try it now |
3 | Table with hover rows | .table-hover | Try it now |
4 | Condensed table | .table-condensed | Try it now |
5 | Responsive tables | .table-responsive | Try it now |
You can use all contextual colors that are default given in Bootstrap utility classes i.e. active, success, info, warning, danger to get the desired color for table presentation.
One can assign different Color by changing the respective color of the elements to get the desired results more effectively.
Row | Default color | New color | Try it Editor |
---|---|---|---|
Bootstrap 3 change table Background color | Transparent | lightgrey | Try it now |
Bootstrap 3 change table Header background Color | Transparent | red | Try it now |
Bootstrap 3 change table row background Color | Transparent | Green | Try it now |
Bootstrap 3 Change table border Color | #ddd | Black | Try it now |
Bootstrap 3 Change table Hover Color | Try it now | ||
bootstrap 3 Table striped Change Color | grey | red | Try it now |
Bootstrap 3 table cell Color | Transparent | Contextual Color | Try it now |
In this you have to specifically use class .table-bordered to get border around all your table cells respectively. This specific class add {border:1px solid #ddd} value to the corresponding table that imparts the bordered layout.
With Class .table-striped you will get table rows in two different color. With this class you will get every odd color to be have specific color to be stripped pattern.
.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.
.table-hover class is added to make table rows change color on hover accordingly. It has following default CSS values that gives it bootstrap table hover to the whole table layout.
.table-hover>tbody>tr:hover{background-color:#f5f5f5}
To make condensed table in Bootstrap you need to add .table-condensed specific class to the table structure which will impart the desired behavior.
To make bootstrap table responsive you must add .table-responsive class to the default table structure respectively.
Bootstrap responsive table CSS :
.table-responsive { overflow-x: auto; min-height: 0.01%; } @media screen and (max-width: 767px) { .table-responsive { width: 100%; margin-bottom: 15px; overflow-y: hidden; -ms-overflow-style: -ms-autohiding-scrollbar; border: 1px solid #ddd; } }
Check out simple Bootstrap Table Template with different features and funcitonalities
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…