I am facing an issue with a dynamically added div using JS. The div includes an overlay and a contained element that should scroll along with the page if needed. I want to prevent any scrolling within the div itself, which resizes based on its content. The overlay is set to cover the entire page with width=100% and height=100%. However, when the contained div becomes taller than the viewport, the overlay stops short after the viewport's height.
If my explanation is unclear, you can check out this simplified fiddle to better understand: http://jsfiddle.net/72SU5/
Below is the CSS code I'm currently using:
#overlay {
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
position: absolute;
top: 0;
z-index: 20;
}
#overlay > div {
width: 100px;
border: 1px solid #ccc;
padding: 20px;
padding-bottom: 40px;
background: #eee;
margin: 50px auto;
}
My question is, how can I make the overlay extend to 100% of the new height once the hidden content is revealed? I am open to using JS/jQuery for this task or even refactoring with a pure-CSS approach if it provides a solution where the overlaying content scrolls along with the page when necessary.