表格
用于控制表格布局算法的实用工具。
类 | 样式 |
---|---|
table-auto | table-layout: auto; |
table-fixed | table-layout: fixed; |
使用 table-auto
实用工具自动调整表格列的大小以适应单元格的内容
歌曲 | 艺术家 | 年份 |
---|---|---|
The Sliding Mr. Bones (Next Stop, Pottersville) | Malcolm Lockyer | 1961 |
Witchy Woman | The Eagles | 1972 |
Shining Star | Earth, Wind, and Fire | 1975 |
<table class="table-auto"> <thead> <tr> <th>Song</th> <th>Artist</th> <th>Year</th> </tr> </thead> <tbody> <tr> <td>The Sliding Mr. Bones (Next Stop, Pottersville)</td> <td>Malcolm Lockyer</td> <td>1961</td> </tr> <tr> <td>Witchy Woman</td> <td>The Eagles</td> <td>1972</td> </tr> <tr> <td>Shining Star</td> <td>Earth, Wind, and Fire</td> <td>1975</td> </tr> </tbody></table>
使用 table-fixed
实用工具忽略表格单元格的内容,并为每列使用固定宽度
歌曲 | 艺术家 | 年份 |
---|---|---|
The Sliding Mr. Bones (Next Stop, Pottersville) | Malcolm Lockyer | 1961 |
Witchy Woman | The Eagles | 1972 |
Shining Star | Earth, Wind, and Fire | 1975 |
<table class="table-fixed"> <thead> <tr> <th>Song</th> <th>Artist</th> <th>Year</th> </tr> </thead> <tbody> <tr> <td>The Sliding Mr. Bones (Next Stop, Pottersville)</td> <td>Malcolm Lockyer</td> <td>1961</td> </tr> <tr> <td>Witchy Woman</td> <td>The Eagles</td> <td>1972</td> </tr> <tr> <td>Shining Star</td> <td>Earth, Wind, and Fire</td> <td>1975</td> </tr> </tbody></table>
您可以手动设置某些列的宽度,剩余的可用宽度将在没有显式宽度的列之间平均分配。第一行中设置的宽度将设置整个表格的列宽。
前缀a table-layout
实用工具 带有断点变体,例如 md:
,仅在以下情况下应用该实用工具中等 屏幕尺寸及以上
<div class="table-none md:table-fixed ..."> <!-- ... --></div>
在变体文档中了解有关使用变体的更多信息。