I am trying to lay one div over another. It is really simple if you know the dimensions of the div.
Solved here: How to overlay one div on another div
So here is my HTML:
<div class="container"> <div class="overlay"></div> <div class="content"></div> </div>
In my case, I do not know the exact dimensions of the "content" or "container". This is due to the fact that I do not have control over the content in the div (we make our application extensible for third-party developers).
Take a look at my jsFiddle example. The overlay should fully cover the content. 100% width and 100% height. However, this does not work, because in my example I completely positioned the overlay.
One solution is to use JavaScript to get the size of the contents of the div, and then set the size of the overlay. I do not like this solution, because if the sizes of the images are not specified, you need to wait until the images are loaded, and recount the size of the div.
Is there a way to solve this problem in CSS?
source share