【发布时间】:2016-05-12 16:20:35
【问题描述】:
我见过 Jquery 插件和 CSS 样式来冻结表格的标题。有没有冻结前两行。我的第二行包含一个用于搜索的文本框。我不能为行指定固定宽度。
<table>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text"/></td>
<td><input type="text"/></td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
你会使用 DataTables 吗?
-
“冻结”是什么意思?
-
@Aziz 冻结标题。固定标题。
-
那么,添加
position: fixed;会发生什么?您可以使用tr:nth-child(-n+2)伪选择器使用 CSS 定位表的第一行 -
这些插件将任何 CSS 样式应用于标题行也需要应用于
tbody tr:first-child。