I have two containers (container1 and container2) and in container1 I have a child element. This child element is absolutely positioned and half the element overlaps over container2. I understand if I add opacity to container1 all it's child elements inherent the property but if I add opacity to container2 it ends up effecting the child element of container1 even though container2 is not it's parent element. An explanation would be very helpful.
Here is the HTML code:
<body>
<div id="container1" style='height: 250px; background-color: red'>
<div id="child" style="height: 290px; width: 200px; background-color: green; position: absolute; top: 100px; left: 30%"></div>
</div>
<div id="container2" style="height: 250px; background-color: purple; font-size: 130px; opacity: 0.5">Some really big text</div>
</body>
Here is a screenshot of what's happening: https://i.stack.imgur.com/A84Li.png