8

When you go to page on my website where there is extra content, the scrollbar appears on the right, but it has a notiable shift to the left for my content. You notice this by clicking home and then hosting and back again on my site (www.ipalaces.org)

How can I account for the browser scrollbar on my pages? Can I make it so the scrollbar is always visible atleast?

My website is www.ipalaces.org, please let me know.

4

6 回答 6

11

好吧,这取决于浏览器。

body {

overflow-y: scroll;
overflow-x: scroll;
overflow: -moz-scrollbars-vertical;

}

应强制显示水平 ( overflow-x) 和垂直滚动条 ( overflow-y)。尽管我记得 Opera 有时会不遵守声明,除非它位于<body>(div 等)内的元素上。


针对@wsanville和@BHare 的评论进行了编辑。

于 2009-07-29T22:46:17.690 回答
7

我已经在 IE6、IE7、IE8、Firefox 3 和 Chrome 上对此进行了测试,让垂直滚动条始终可见的简单方法很简单:

html { overflow-y: scroll; } 
于 2010-09-09T14:15:56.873 回答
3

让你的身体 101% 高...这将强制滚动条始终显示。

body {height:101%}
于 2009-07-29T23:59:16.813 回答
1

这似乎对我很有用......

html {
    overflow-y: scroll;
}
于 2012-09-02T18:25:55.700 回答
1

试一试...我知道它很丑,但它可能是唯一的方法。

#force_scroll { 
    width: 1em; 
    position: absolute; 
    top: 0; 
    bottom: -0.1px; 
    z-index: -1; 
}

然后在您的 HTML 中某处(最好在您的 之前</body>):

<div id="force_scroll"></div>
于 2009-07-30T20:11:06.867 回答
1
body {
   overflow: scroll;
}

即使是最新的 Firefox (3.5),我也遇到了同样的问题。溢出功能救了我的命!

于 2009-10-03T09:38:06.573 回答