I would like to disable browser's scrolling when an event happens, but not remove the scrollbar ?
我想在事件发生时禁用浏览器的滚动,但不删除滚动条?
I would like something very similar to setting CSS's overflow:hidden
to the whole document. My reason is that doing so changes the browser's width, hence I will have to re-align the body.
我想要一些非常类似于设置CSS的溢出:隐藏到整个文档。我的理由是这样做会改变浏览器的宽度,因此我将不得不重新对齐身体。
2 个解决方案
#1
0
The best practise fix to the problem I think you're describing is this simple CSS:
我认为你正在描述的问题的最佳实践修复是这个简单的CSS:
html {
overflow-y: scroll
}
That forces the vertical scrollbar to always be visible, so that the browser's width will not change "when an event happens", and you won't "have to re-align the body".
这会强制垂直滚动条始终可见,因此浏览器的宽度不会“在事件发生时”改变,并且您不会“必须重新对齐身体”。
#2
0
Why not just set the entire web page to align:center? No manual re-aligning, and works with any screen resolution or browser :-)
为什么不将整个网页设置为align:center?没有手动重新对齐,适用于任何屏幕分辨率或浏览器:-)
#1
0
The best practise fix to the problem I think you're describing is this simple CSS:
我认为你正在描述的问题的最佳实践修复是这个简单的CSS:
html {
overflow-y: scroll
}
That forces the vertical scrollbar to always be visible, so that the browser's width will not change "when an event happens", and you won't "have to re-align the body".
这会强制垂直滚动条始终可见,因此浏览器的宽度不会“在事件发生时”改变,并且您不会“必须重新对齐身体”。
#2
0
Why not just set the entire web page to align:center? No manual re-aligning, and works with any screen resolution or browser :-)
为什么不将整个网页设置为align:center?没有手动重新对齐,适用于任何屏幕分辨率或浏览器:-)