javascript - 如何卡住表的 head 部分

标签 javascript jquery html css

我有一个包含两个标题行的表 Demo .

<thead>
    <tr>
       <th colspan="4"><big>Variable Details</big></th>
    </tr>
    <tr>               
       <th>Variable Name</th>
       <th>Starting Value</th>
       <th>Default Value</th>
       <th>Description</th>
     </tr>
 </thead>

我想卡住前两个标题行(表格的标题部分)。有什么想法。

最佳答案

将 CSS 属性位置更改为“粘性”以获得粘性表格头。见下文。

CSS:

thead { 位置:粘性;顶部:0px; z 索引:10; }

注意:您可能需要根据其他 CSS 属性调整 z-index。

关于javascript - 如何卡住表的 head 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18848369/

相关文章:

jquery - Bootstrap 3.0 中的水平导航菜单 - 如果我有很多主菜单,如何在其顶部添加上一个-下一个箭头?

javascript - 如何在 cookie 中存储并检索图像的链接?

javascript - 当使用绑定(bind)进行 eval 时,Nashorn 找不到函数

javascript - 在 render prop 函数中使用 react hooks

javascript - jQuery 多个按钮单击时显示和隐藏元素

javascript - 仅当某个 div 的高度大于设置高度时才显示 div?

html - 无法在谷歌浏览器中显示输出

html - 缩小时我的网站设计变得困惑,我该如何解决?

javascript - 如何更改dimple.js中工具提示的位置和大小

javascript - 拼接数组中的值并将拼接后的值推送到另一个数组中