开发者

How do we disable - not hide - scrollbars in a browser using jQuery?

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 wi开发者_运维问答ll 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".


Why not just set the entire web page to align:center? No manual re-aligning, and works with any screen resolution or browser :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜