Always show browser scrollbar to prevent page jump

2019-01-11 06:16发布

Possible Duplicate:
How to always show scrollbar in browser using javascript?

Some pages I have have lots of content other pages have a few lines, so when I am clicking between pages some pages have a scrollbar on the browsers and others don't. Because of this the page jumps all the time due to the extra space when clicking between pages.

Is it possible to have the scrollbar visible at all times, or greyed out if there is not a lot of content to stop the jumping of pages?

Can it work across all browsers, hope someone can help,

Cheers

2条回答
Explosion°爆炸
2楼-- · 2019-01-11 06:49
html {
    overflow-y: scroll; 
}

It is the best solution.

查看更多
\"骚年 ilove
3楼-- · 2019-01-11 06:55

Try reading this article by Chris Coyer, it explains it pretty well.

From the article:

Assigning overflow-y to scroll does work, and it works in Firefox, Safari, and IE 6, and that makes it the best solution:

html {
    overflow-y: scroll; 
}
查看更多
登录 后发表回答