如何禁用滚动body元素?

时间:2010-05-07 14:02:52

标签: jquery

如何禁用身体滚动? $('body').css('overflow','hidden');仅隐藏滚动条,但不会禁用滚动。我想禁用身体的滚动。

但我想保持其他部门的滚动完整。

1 个答案:

答案 0 :(得分:8)

试试这个CSS,不需要jQuery:

<style type="text/css">
    html { overflow: hidden; }
</style>

[评论后更新]

尝试同时指定body的高度:

<style type="text/css">
    html, body { overflow: hidden; height: 100% }
    body { margin:0; padding:0; }
</style>