In the following example, an absolute child div is contained in a relative parent. The div preceding the parent is shown and hidden conditionally so the parent div should be aligned to the top whether or not the header is displayed.
The problem is when the header is displayed, the contents of the child div are hidden even if you scroll (the bottom of the scroll bar cannot be seen). How can the bottom of the child div be the bottom of the parent div (in this case the browser window)?
html {
height: 100%;
margin: 0;
overflow: hidden;
}
body {
margin: 0;
height: 100%;
}
#parentDiv
{
position:relative;
background: yellow;
height: 100%;
}
#childDiv
{
position:absolute;
left:50px;
top:20px;
bottom: 0;
background: blue;
overflow: auto;
}
<div id='header'>This header causes childDiv to scroll outside of the browser window (bottom scroll thumb isn't visible).
This toggles so parentDiv should adjust up when not visible.
</div>
<div>
<div id='parentDiv'>
This is the parent div
<div id='childDiv'>
This is the child div <br>
This is the child div <br>
(Repeat to extend beyond browser window and cause a scroll bar to be displayed)
...
This is the child div <br>
</div>
</div>
</div>