Search

10/16/2007

Always Show Vertical Scrollbar in Firefox [firefox] [css] [web]

Always Show Vertical Scrollbar in Firefox [firefox] [css] [web] - 為什麼要always show vertical scrollbar in Firefox?在IE中,vertical scroll bar 會一直在,不管content的長短,這反而解決了一個問題:在一個置中的欄位中,如果內容太長,Firefox會出現 scrollbar並且佔掉部分的document width,導致置中的欄位移動,畫面不美觀,目前沒有太好的解決辦法,先讓FF的scrollbar一直在吧。

/* always show scrollbar in FF  */
html {
overflow: -moz-scrollbars-vertical;
}
/* hide necessary scrollbar for textarea in IE */

* html textarea{
overflow:auto;
}

update: there's a side effect: horizontal scrollbars will never appear
* -moz-scrollbars-horizontal: Indicates that horizontal scrollbars should always appear and vertical scrollbars should never appear.
* -moz-scrollbars-vertical: Indicates that vertical scrollbars should always appear and horizontal scrollbars should never appear.
* -moz-scrollbars-none: Indicates that no scrollbars should appear but the element should be scrollable from script. (This is the same as hidden, and has been since Mozilla 1.6alpha.)

Forcing Firefox to always show a scroll bar - TOLRA Community Forums
Adding the following to your CSS file causes Firefox to always show the scroll bar:
Code:

html { min-height: 100%; margin-bottom: 1px; }

The normal operation is for Firefox to remove the scroll bar if it's not needed which can lead to the page shifting left and right slightly between long and short pages.

update: this is one perfect solution
Always Show Vertical Scrollbar in Firefox [firefox] [css] [web]
html {overflow: scroll;} works but it also gives you a horizontal scroll bar.
html {overflow-y: scroll;} will give you just a vertical scroll bar, if that's what you are going for.

沒有留言: