Please consider this fiddle: http://jsfiddle.net/eKJAj/
I'm trying to have an absolute positioned div (the red line) to take the whole height of the total height of its (yellow) parent ; not just the parent's visible height.
If you try the fiddle you'll see the red bar doesn't go the whole way down when you scroll the yellow div. Also it can't be bigger than its parent if some blue sections are removed.
html:
<div class="parent">
<div class="bar"></div>
<div class="section"></div>
<div class="section2"></div>
<div class="section2"></div>
<div class="section2"></div>
<div class="section2"></div>
<div class="section2"></div>
<div class="section"></div>
</div>
<input type="button" value="hide" onclick="$('.section2').slideUp(400)" />
<input type="button" value="show" onclick="$('.section2').slideDown(400)" />
css:
.parent{
position:relative;
width:100%; max-height:300px;
background-color:yellow;
overflow-y:auto;
}
.bar{
position:absolute; left:50px;
width:1px; height:100%;
background-color:red;
}
.section, .section2{
width:100%; height:70px;
margin-bottom:3px;
background-color:blue;
}
I have been trying a few options for the blue bar such as top:0px; botom:0px
or position:relative; margin-left:50px
and even made an attemps with floating the red line, to no avail.
If possible I'd rather keep it CSS only. Any hint much appreciated!!