在2018 年的 工作日上保持 粘性!
在样式表中,只需添加以下一行:
thead th { position: sticky; top: 0; }您的表将需要包含 thead 和 th 才能进行样式设置。
<table> <thead> <tr> <th>column 1</th> <th>column 2</th> <th>column 3</th> <th>column 4</th> </tr> </thead> <tbody> // your body pre </tbody></table>
另外,如果 thead中 有多行,则可以选择第一个保持粘性:
thead tr:first-child th { position: sticky; top: 0; }


