Skip to content Skip to sidebar Skip to footer

How To Set Up The Browser Scrollbar To Scroll Part Of A Page?

I've seen this done in a few sites, an example is artofadambetts.com. The scroll bar on the page scrolls only an element of the page, not the entire page. I looked at the source an

Solution 1:

That's pretty nifty. He uses "position:fixed" on most of the divs, and the one that scrolls is the one that doesn't have it.

Solution 2:

In fact it is not the scrolling part that is "doing the job", it is the fixed part of the page.

In order to do this, you should use CSS and add position: fixed; property (use it with top, bottom, left and/or right properties) to the elements that you wish not to scroll.

And you should not forget to give them a greater z-index, if you don't there might be some of the scrolling element that can go over your fixed element as you scroll (and you certainly don't want that).

Solution 3:

To find out how people do these kinds of things in CSS and/or Javascript the tool Firebug is just outstanding:

Firebug addon for Firefox

Solution 4:

It should be noted that without further hacks position fixed does not work for IE6, which is still managing to hold on to 15-30% of the market, depending on your site.

Solution 5:

You can use fixed positioning or absolute positioning to tie various elements to fixed positions on the page. Alternatively you can specify a fixed size element (such as a DIV) and use overflow: scroll to force the scrollbars on that.

As already mentioned, getting everything to work in Internet Explorer AND Firefox/Opera/Safari requires judicious use of hacks.

Post a Comment for "How To Set Up The Browser Scrollbar To Scroll Part Of A Page?"