* {
margin: 0;
padding: 0;
}
div#parent {
position: relative;
}
div#container {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
img {
position: absolute;
width: 100%;
}
<body>
<div id="parent">
<img src="bg.jpg" draggable="false">
<div id="container"></div>
</div>
</body>
I'm using the <img>
as a background. I want the #container
to be on top of the "background" and to have the same dimensions as the background. How may I achieve that without JavaScript?