我们如何禁用 - 不隐藏 - 使用jQuery浏览器中的滚动条? [英] How do we disable - not hide - scrollbars in a browser using jQuery?
问题描述
我想在事件发生时停用浏览器的滚动功能,但不能移除滚动条?
我希望能够将CSS的 overflow:hidden
设置为整个文档。我的理由是这样做会改变浏览器的宽度,因此我将不得不重新调整主体。 解决方案
最佳实践
html {
overflow-y:scroll
}
强制垂直滚动条始终可见,所以浏览器的宽度不会在事件发生时发生改变,而且你不会必须重新排列正文。
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.
The best practise fix to the problem I think you're describing is this simple 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".
这篇关于我们如何禁用 - 不隐藏 - 使用jQuery浏览器中的滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!