I can't understand why a div positioned as absolute inside a relative div overlaps other elements. As far as I can understand, its position should be fix in its relative div container and encompassed in it, shouldn't it?
My attempt:
#content {
position: relative;
}
#overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
background-image: url(https://picsum.photos/800);
background-size: cover;
}
<div id="before">
some div
</div>
<div id="content">
<div id="overlay">
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
<div>Some text.</div>
</div>
</div>
<div id="after">
other div
</div>
I wonder why #content, positioned as relative, overlaps #after.