1

我正在尝试在不使用 Javascript 的情况下为 thead 获取一个固定的表头。这是我的表的基本设置:

<table>
   <thead>
     <tr>
       <th>...</th>
       <th>...</th>
       <th>...</th>
    <tr>
   </thead>
   <tbody>
       ...
   </tbody>
</table>

我尝试使用 css,但没有成功。我有一个固定的标题,但它的宽度很小而且不可调节。

.thead {
    position:fixed;
    top:0;
    width:100%;
}
4

1 回答 1

3

尝试这个

<table>
   <thead class="fixedthead">
     <tr>
       <th>...</th>
       <th>...</th>
       <th>...</th>
    <tr>
   </thead>
   <tbody>
       ...
   </tbody>
</table>

.fixedthead{position:fixed; top:0px;}
于 2017-04-26T06:47:26.123 回答