我试图在不使用Javascript的情况下为thead获取固定的表头。这是我的表的基本设置:
<table>
<thead>
<tr>
<th>...</th>
<th>...</th>
<th>...</th>
<tr>
</thead>
<tbody>
...
</tbody>
</table>
我尝试使用css但没有成功实现它。我有一个固定的标题,但它的宽度很小,不可调整。
.thead {
position:fixed;
top:0;
width:100%;
}
答案 0 :(得分:3)
试试这个
<table>
<thead class="fixedthead">
<tr>
<th>...</th>
<th>...</th>
<th>...</th>
<tr>
</thead>
<tbody>
...
</tbody>
</table>
.fixedthead{position:fixed; top:0px;}