THE PROBLEM
I have two DIV elements: #container and #child. The #container is scrollable and the #child must take the full height of the #container. However the #child does not take the full height of the #container. Note that the #container has a dynamic height so the #child always has to use the same height.
The problem is shown HERE (JSFiddle).
<div id="container">
<div id="child"></div>
</div>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
}
#container {
position: relative;
width: 80%;
height: 80%;
overflow-y: auto;
background-color: lightgrey;
}
#child {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 50px;
background-color: lightcoral;
}
I actually have a quite good JavaScript solution for this HERE (JSFiddle). But does anyone know a decent CSS-only solution for this? Would be so much simpler.