我们如何禁用 - 不隐藏 - 使用jQuery浏览器中的滚动条? [英] How do we disable - not hide - scrollbars in a browser using jQuery?

查看:131
本文介绍了我们如何禁用 - 不隐藏 - 使用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屋!

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