jquery - 在 html 表格中卡住标题

标签 jquery html css freeze

在这里,我有一个表,我想在滚动时修复该表头

JS

<script>
$('#scroll').scroll(function(){
if ($('#scroll').scrollTop() > 10){
    $("thead").css({
            position: 'fixed',
            top: '68px'
        });
}else{
    $('thead').css({
        position: 'static'
    });
}
});
</script>

这是完美的,但设计正在改变。

LIVE DEMO

谁能帮帮我。

提前致谢。

编辑

Fiddle

最佳答案

您可以使用 datatables plugin具有不同的表类型(fixed header table, example)

关于jquery - 在 html 表格中卡住标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20392574/

相关文章:

html - html 页面上动态粘贴在底部的页脚

javascript - 当你滚动到它时获取一组 div 的索引

javascript - JQuery 使用计时器在 for 循环中更改 CSS

javascript - CSS 背景色有效性

jquery - 链接在我的模板上不起作用

javascript - 下拉菜单位于 bootstrap 3 的面板下

html - 位置固定和溢出-y :scroll issue

javascript - Ajax 调用 Web API 在 Chrome 中有效,但在 Edge 中无效

jquery - CSS 位置 :fixed not fixed in Mobile Safari. .. 再次

html - 如何在 NetBeans 中禁用 "HTML Checking"?