Table Layout 表格布局
控制表格布局算法的实用工具。
| Class | Properties |
|---|
基本用法
Auto 自动
使用 table-auto 来允许表格自动调整列宽以适应单元格内容。
| Song | Artist | Year |
|---|---|---|
| The Sliding Mr. Bones (Next Stop, Pottersville) | Malcolm Lockyer | 1961 |
| Witchy Woman | The Eagles | 1972 |
| Shining Star | Earth, Wind, and Fire | 1975 |
html
<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>Fixed 固定
使用 table-fixed 来让表格忽略内容,并对列使用固定宽度。第一行的宽度将设置整个表格的列宽。
您可以手动设置一些列的宽度,其余可用宽度将均匀分配给没有明确宽度的列。
| Song | Artist | Year |
|---|---|---|
| The Sliding Mr. Bones (Next Stop, Pottersville) | Malcolm Lockyer | 1961 |
| Witchy Woman | The Eagles | 1972 |
| Shining Star | Earth, Wind, and Fire | 1975 |
html
<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>有条件地应用
悬停、焦点和其他状态
Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:table-fixed 只在悬停时应用 table-fixed 实用程序。
html
<table class="hover:table-fixed">
<!-- ... -->
</table>要查看所有可用状态修饰符的完整列表,请查阅悬停、焦点和其他状态文档。
断点和媒体查询
您还可以使用变体修饰符来定位媒体查询,比如响应式断点、暗模式、偏好减少动作等。例如,使用 md:table-fixed 仅在中等屏幕尺寸及以上应用 table-fixed 实用程序。
html
<table class="md:table-fixed">
<!-- ... -->
</table>