tags:

views:

2976

answers:

5

Hi

I saw a trick once on a website which made the main scrollbar of the page always stay visible. I can't remember how it was done. Does anyone know?

+4  A: 
html {
  overflow-y: scroll;
}

Is that what you want?

Unfortunately, Opera 9.64 seems to ignore that CSS declaration when applied to HTML or BODY, although it works for other block-level elements like DIV.

Ionuț G. Stan
+15  A: 
html {
overflow: -moz-scrollbars-vertical; 
overflow-y: scroll;
}

This make the scrollbar always visible and only active when needed.

Corv1nus
Do you have any idea what version of FF brought support for `overflow-y`? As it seems that `-moz-scrollbars-vertical` is deprecated in favor of the `overflow-y` property.
Ionuț G. Stan
I think Internet Explorer 6.x+, Firefox 1.5+ if I remember correctly. I've been using the above code and it works in FF1.5-3.5.1 and IE6-8 for me.
Corv1nus
Thanks, +1. I forgot about that `-moz` property.
Ionuț G. Stan
Old Post, but I love how searching SO is faster by far then searching google. +1
Erik
A: 

Try make the body height:101%. Thats the best solution in my opinion.

body {height:101%; }
Joseph Silvashy
Does not work here.
Deniz Dogan
A: 

I've found a way to make this work in the browsers of ye 'ol... err IE.

Yah it's ugly... I posted it here also http://stackoverflow.com/questions/1203503/browser-scrollbar-shift/1209046#1209046

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

And then in your HTML somewhere (preferably right before your ):

<div id="force_scroll"></div>
Joseph Silvashy
+1  A: 
html {height: 101%;}

I use this cross browsers solution (I use DOCTYPE declaration in 1st line, I don't know if it works in quirksmode, never tested it).

This will always show an ACTIVE vertical scroll bar in every page, vertical scrollbar will be scrollable only of few pixels.

When page contents is shorter than browser's visible area (view port) you will still see the vertical scrollbar active, and it will be scrollable only of few pixels.

By using this solution your CSS code would validate for W3C because you are not using non standard CSS attributes.

Marco Demajo