I have an overlay which should fill an entire div.
HTML:
<div class="phone">
<div class="overlay"></div>
</div>
CSS:
.phone {
position: relative;
width: 300px;
height: 500px;
padding: 15px;
background: #F2F4F5;
overflow: hidden;
cursor: default;
}
.overlay {
display: none;
background: rgba(27, 35, 41, 0.5);
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
I have some JS adding content to the .phone div and when content is added, it automatically scrolls to the bottom of the .phone div. However, the overlay only stretches to fit the 300x500 original size. So when it scrolls down the overlay no longer covers the entire div.
If I add position: fixed to the overlay, it fills the whole screen instead of the .phone div only.
