Previous words
Bootstrap provides us with very beautiful and easy-to-use table styles. You can use Boosttrap to quickly create tables of different styles. This article will introduce Boosttrap tables in detail
Basic example
Boosttrap resets the style of the table <table> as follows
1 2 3 4 5 | table {
background-color: transparent;
border-spacing: 0;
border-collapse: collapse;
}
|
Copy after login
1 2 3 4 5 6 | <table>
<caption>Optional table caption.</caption>
<thead><tr> <th>#</th> <th>First Name</th> <th>Last Name</th> <th>Username</th></tr>
</thead>
<tbody><tr> <th scope= "row" >1</th> <td>Mark</td> <td>Otto</td> <td>@mdo</td></tr><tr> <th scope= "row" >2</th> <td>Jacob</td> <td>Thornton</td> <td>@fat</td></tr><tr> <th scope= "row" >3</th> <td>Larry</td> <td>the Bird</td> <td>@twitter</td></tr>
</tbody></table>
|
Copy after login
Add the .table
class to any <table>
tag to give it a basic style—a small amount of padding and a horizontal divider
1 2 | <table class = "table" >
...</table>
|
Copy after login
Striped table
Through the .table-striped
class you can give Add a zebra stripe style to each row within <tbody>
[Note] The striped table is implemented by relying on the
:nth-child
CSS selector, and This feature is not supported by IE8- ## Add the .table-bordered
class to add borders to the table and each cell in it
1 2 3 | .table-striped > tbody > tr:nth-of-type(odd) {
background-color: #f9f9f9;
}
|
Copy after login
Mouse hover
By adding the .table-hover class, each row in <tbody> can respond to the mouse hover state
1 2 | <table class = "table table-striped" >
...</table>
|
Copy after login
1 2 | <table class = "table table-bordered" >
...</table>
|
Copy after login
Condensed table
By adding the .table-condensed class, the table can be made more compact and the padding in the cells ) will be halved
1 2 | <table class = "table table-hover" >
...</table>
|
Copy after login
State Class
Through these status classes, rows or units can be Grid setting color
1 2 3 | .table-hover > tbody > tr:hover {
background-color: #f5f5f5;
}
|
Copy after login
1 2 | <table class = "table table-condensed" >
...</table>
|
Copy after login
##Responsive form
Change any. The table element is wrapped in a .table-responsive element to create a responsive table that will scroll horizontally on small screen devices (less than 768px). When the screen is larger than 768px width, the horizontal scroll bar disappears
1 2 3 4 5 6 | Class 描述
.active 鼠标悬停在行或单元格上时所设置的颜色
.success 标识成功或积极的动作
.info 标识普通的提示信息或动作
.warning 标识警告或需要用户注意
.danger 标识危险或潜在的带来负面影响的动作
|
Copy after login
The above is the detailed content of Create table instances using Boostrap. For more information, please follow other related articles on the PHP Chinese website!