cdu*_*dub 4 html css jquery html-table css-position
我有一个带有标题和正文的表格,我希望表格标题在主体上滚动时保持固定.
该表设置如下:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
...more rows for data...
</tbody>
Run Code Online (Sandbox Code Playgroud)
该表用一个封装,并具有CSS,如:
overflow-x: hidden;
overflow-y: auto;
height: 400px;
Run Code Online (Sandbox Code Playgroud)
我需要表头保持完全静止,但当我添加position:fixed; 对于thead或个人而言,标题会被压扁.
这是最好的方法吗?