Best way to have right scroll bar only control specific div

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
Hi Guys,

I have a website template that has a header, and below the header are 3 divs. The divs are left, middle, and right.

Most of the content will be in the middle, and the left/right divs are preconfigured to not take up any more page space than what's above the fold.

If the center div's content goes beyond the page fold, the scroll bar appears. However, this will scroll the entire page. I'd like it to only scroll the center div and leave the rest of the page static and in place.

Rnuiw.png


I want to be able to scroll ONLY the 'scrollable' content and use the browsers main scroll bar.

Thoughts? can this be done without javascript and only css?
 

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
From what I'm reading, the best way to do it is to set the 'non scrolling' divs to fixed. What's not position fixed, is what will scroll with the scroll bar.

I would need to set the position:fixed attribute to the Header/Sidebar1/Sidebar2 elements. So when the center content grew passed the fold and I scrolled, those elements would remain in the same fixed position.
 

GregGreen

Golden Member
Dec 5, 2000
1,682
3
81
1. The fold as it relates to web design doesn't exist. Erase it from your memory bank.
2. display: fixed; top: someValue; left: someOtherValue;
 

xanis

Lifer
Sep 11, 2005
17,571
8
0
If the two side divs aren't ever going to move, throw a position: fixed; on them and use your margins to set the location.