如何禁用身体元素的滚动? [英] How to disable scrolling of body element?

查看:64
本文介绍了如何禁用身体元素的滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to disable scrolling of body? $('body').css('overflow','hidden'); only hides the scrollbars but it does not disable the scrolling. I want to disable the scrolling of the body.

但是我想保持其他分区的滚动不变.

But I want to keep the scrolling of other division intact.

推荐答案

尝试使用此CSS,无需使用jQuery:

Try this CSS, no jQuery needed for this:

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


[评论后更新]


[UPDATE after comment]

也尝试指定body的高度:

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

这篇关于如何禁用身体元素的滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆