禁用身体上的滚动 [英] Disable Scrolling on Body

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

问题描述

我想完全禁止在HTML body上滚动.我尝试了以下选项:

I would like to disable scrolling on the HTML body completely. I have tried the following options:

  • overflow: hidden;(不起作用,没有禁用滚动,它只是隐藏了滚动条)

  • overflow: hidden; (not working, did not disable scrolling, it just hid the scrollbar)

position: fixed;(此方法有效,但是它完全滚动到顶部,这对于该特定应用程序是不可接受的)

position: fixed; (this worked, but it scrolled completely to the top, which is unacceptable for this specific application)

我无法找到这两个选项的替代方案,还有吗?

I was unable to find any alternatives to these two options, are there any more?

推荐答案

设置heightoverflow:

html, body {margin: 0; height: 100%; overflow: hidden}

http://jsfiddle.net/q99hvawt/

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

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