表格 ·续1
<table class="table table-sm table-dark"> <thead> <tr> <th scope="col">#</th> <th scope="col">First Name</th> <th scope="col">Last Name</th> <th scope="col">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 colspan="2">Larry the Bird</td> <td>@twitter</td> </tr> </tbody></table>
语义状态化
使用语义状态样式对表格逐行或单个单元格进行着色表达。
<!-- On rows --><tr class="table-active">...</tr><tr class="table-primary">...</tr><tr class="table-secondary">...</tr><tr class="table-success">...</tr><tr class="table-danger">...</tr><tr class="table-warning">...</tr><tr class="table-info">...</tr><tr class="table-light">...</tr><tr class="table-dark">...</tr><!-- On cells (`td` or `th`) --><tr> <td class="table-active">...</td> <td class="table-primary">...</td> <td class="table-secondary">...</td> <td class="table-success">...</td> <td class="table-danger">...</td> <td class="table-warning">...</td> <td class="table-info">...</td> <td class="table-light">...</td> <td class="table-dark">...</td></tr>
深色表格上没有固定的背景,你可以使用 文字或背景通用样式 获得类似的样式:
<!-- On rows --><tr class="bg-primary">...</tr><tr class="bg-success">...</tr><tr class="bg-warning">...</tr><tr class="bg-danger">...</tr><tr class="bg-info">...</tr><!-- On cells (`td` or `th`) --><tr> <td class="bg-primary">...</td> <td class="bg-success">...</td> <td class="bg-warning">...</td> <td class="bg-danger">...</td> <td class="bg-info">...</td></tr>
向使用辅助技术的用户传达用意
使用颜色添加意义只提供一个视觉指示,这不会传达给辅助技术的用户,如屏幕阅读器。确保由颜色表示的信息从内容本身(例如可见文本)中显而易见,或者通过替代方法包括,例如隐藏在.sr-only该类中的附加文本。
通过包装任何响应创建表.table用.table-responsive{-sm|-md|-lg|-xl},使表滚动水平在每一个max-width的断点分别高达576px,768px,992px和1120px,(但不包括)。
请注意,由于浏览器目前不支持范围方面的查询,我们解决的局限性min-和max-前缀和视口带小数的宽度(可下的高DPI设备一定的条件下发生,例如)通过使用值与这些比较高的精度。
Captions表格辅助标题
<caption> 标签如同一个表格的标题,它默认是隐藏的,可以协助屏幕阅读器用户找到表格、了解表格内容,且决定是否需要阅读它。
<table class="table"> <caption>List of users</caption> <thead> <tr> <th scope="col">#</th> <th scope="col">First Name</th> <th scope="col">Last Name</th> <th scope="col">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>
响应式表格
当表格想要始终呈现水平滚动,可在.table上加入.table-responsive获得响应式表现,从而支持任何viewport窗口。也可以在.table上,加 .table-responsive{-sm|-md|-lg|-xl}属性来定义多屏幕尺寸响应支持。
垂直剪裁/缩减
当响应式表格超过表格底部或顶部边缘,会通过 overflow-y: hidden属性将内容隐藏,总的说这会隐藏掉下拉列表或第三方的插件展现。
总是响应
为兼容各个屏幕规格断点,添加 .table-responsive 选择器使表格支持水平响应。
<div class="table-responsive"> <table class="table"> ... </table></div>
多屏幕断点设定
使用 .table-responsive{-sm|-md|-lg|-xl}可以根据需要对不同屏幕尺寸断点表格进行响应式设计,在中断点之上该表格会正常显示,而不是水平滚动(没有水平条)。
在响应样式应用于特定视口宽度之前,这些表可能会断开.
<div class="table-responsive-sm"> <table class="table"> ... </table></div>
<div class="table-responsive-md"> <table class="table"> ... </table></div>
<div class="table-responsive-lg"> <table class="table"> ... </table></div>
<div class="table-responsive-xl"> <table class="table"> ... </table></div>
