About this article:
Posted in: Learned along the way
By: Blockcoder ( Admin ) / 10.12.2012
Stats: 2 responses / Views: 1,960
Tags: css, scrollbar
Hi there, here’s a new block of code, so called code snippet and it is about “how to force your browser’s scrollbar to fix to the right side” – and stay there.
This situation is familiar and maybe needed when you have content that differs with it’s height property. In some subpage it throws the scrollbar and in another it doesn’t because of the different height of your content. It causes this annoying vertical “bumping”. It is not a good thing. You want to get rid of it. I know. It is simple.
Well, this may be more simplier than you can imagine. Let’s mention one thing before doing any css: IE always forces the scrollbar in the right side of your browser. We don’t know why, but it does. Other browsers doesn’t. There are different methods for different browsers you can follow. You will do the forcing with CSS.
Write this down to your HTML-tag in css. Like this:
html { overflow-y: scroll; }
The specification “overflow-y” was added in CSS3.
But, want to be more specific? Let’s do it for only Mozilla browser:
html { overflow: -moz-scrollbars-vertical; }
So, that’s it. It wasn’t so hard?
blockcoders.net is created and maintained by Johannes; a web developer, actor and media designer living and working in Jyväskylä, Finland.