I have a layout with a vertical scroll. One of the child elements within the scrollable div is absolutely positioned with a large top value, inducing a vertical scrollbar on the parent. The scrollable parent div also has some child div elements (lets call them pillars) positioned horizontally adjacent to each other via position: absolute and some left value.
Here's the HTML markup:
<div id="root" style="height: 250px; position: relative;">
<div class="stretch">
<div id="container" class="container">
<div id="pillar1" style="left: 0.0%; width:33.25%;" class="pillar" ></div>
<div id="pillar2" style="left: 33.05%; width:33.25%;" class="pillar" ></div>
<div id="pillar3" style="left: 66.05%; width:33.25%;" class="pillar" ></div>
<div id="fixed-and-not-movable" style="background: blue; width: 25px; height: 25px; top:350px; left: 150px; position: absolute;">
</div>
</div>
and the CSS:
.stretch {
bottom: 0;
left: 0;
right: 0;
top: 0;
position: absolute;
height: auto;
width: auto;
}
.container {
border: 2px solid;
bottom: 0;
left: 0;
right: 0;
top: 0;
overflow-x: hidden;
overflow-y: scroll;
position: absolute;
}
.pillar {
border: 1px dotted red;
bottom: 0;
height: 100%;
position: absolute;
top: 0;
}
I want the pillar divs to capture the entire scroll height of the parent "container". Right now their height is the parents client height (not scroll height). So when you scroll down you will notice the pillars are not filling all the available height inside the overflow:scroll.
Can someone suggest changes to CSS classes (.container
and/or .pillar
) to make this work.
Here's a link to js fiddle showing the same problem: http://jsfiddle.net/AshwinPrabhuB/2o5whkmq
Thanks!