I have 2 div elements with background-color set overlaying on top of another div with content. In case-1 overlay is not a sibling of the content div so it allow background text to be visible to user. In case-2 the overlay is a sibling of the content div so it is not showing the text to user.
Case-1
<div class="overlay"></div>
<div class="example-container">
<div class="child1">
Case 1 - Sample Text 1
</div>
</div>
Case-2
<div class="child1">
Case 2 - Sample text 2
</div>
<div class="overlay">
</div>
Sample JSfiddle to simulate 2 scenarios.
Any idea why this behavior in html? How could we make the overlay div with background color (case-2) always allow text transparency.