Html 如何使页面不可滚动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12031618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a page unscrollable?
提问by AaronAAA
I have a page I'm working on that encompasses a vertical drop-down menu. However, when the menu drops down, it pushes the text below it downwards and off the page. This is expected, but this enables the scroll bar on the side of the page. I was wondering it there was a way to get rid of this. In other words, it shouldn't just not scroll, but never even offer the option to scroll.
我有一个我正在处理的页面,其中包含一个垂直下拉菜单。但是,当菜单下拉时,它会将其下方的文本向下推离页面。这是意料之中的,但这会启用页面一侧的滚动条。我想知道有没有办法摆脱这种情况。换句话说,它不应该只是不滚动,甚至不应该提供滚动选项。
Thanks!
谢谢!
回答by khaverim
回答by Randall Ma
Use overflow: hidden;
on the element you want to hide the scrollbar on.
使用overflow: hidden;
要隐藏滚动条上的元素。