Bootstrap实现了大量基本样式,包括表格、表单、按钮、图片等。基本的使用方法是通过添加特定的class来实现。
Bootstrap 提供了一个清晰的创建表格的布局。
0x01 表格样式
(1)基本样式:不带边框和分割线:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="nofollow noopener noreferrer" href="../../css/bootstrap.min.css" rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="../../js/bootstrap.min.js"></script> <title>表格</title> </head> <body> <div class="container"> <table class="table"> <tr> <td>序号</td> <td>姓名</td> <td>年龄</td> </tr> <tr> <td>1</td> <td>kikay</td> <td>20</td> </tr> <tr> <td>2</td> <td>Tom</td> <td>18</td> </tr> <tr> <td>1</td> <td>小花</td> <td>21</td> </tr> </table> </div> </body> </html>
(2)样式:table-bordered:为表格带上边框:<table class="table table-bordered table-striped">
(3)样式:table-striped:为表格带上斑马线:<table class="table table-striped">
(4)样式:.table-hover:为鼠标悬浮在表格行上指定不同颜色:<table class="table table-hover">
(5)样式:.table-condensed:使表格更加紧凑:<table class="table table-condensed">
0x02 状态标识
还可以为表格中行或者单元格添加状态样式,比如:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="nofollow noopener noreferrer" href="../../css/bootstrap.min.css" rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="../../js/bootstrap.min.js"></script> <title>带上边框</title> </head> <body> <div class="container"> <table class="table table-bordered table-striped table-hover table-condensed"> <tr class="alert-danger"> <td class=>序号</td> <td>姓名</td> <td>年龄</td> </tr> <tr class="success"> <td>1</td> <td>kikay</td> <td>20</td> </tr> <tr class="alert-warning"> <td>2</td> <td>Tom</td> <td>18</td> </tr> <tr> <td>1</td> <td>小花</td> <td>21</td> </tr> </table> </div> </body> </html>
如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题:
Bootstrap学习好代码教程
Bootstrap实战好代码教程
Bootstrap插件使用好代码教程
本文Bootstrap基本样式学习笔记之表格(2)到此结束。每个成功者都有一个开始。勇于开始,才能找到成功的路。小编再次感谢大家对我们的支持!