Given my code below:
img
{
width:400px;
}
div {
border:2px solid blue;
width:200px;
height:100px;
margin-top:-70px;
z-index:999999999;
}
<img src="https://i.gyazo.com/ee6bb88b3da7ce038475b8ce27fb5fbb.jpg" />
<div>
</div>
Logically speaking, the <div>
is created after the <img>
, so <div>
should overlap the <img>
element when I give it a negative margin
. But why is the <img>
element covering the <div>
instead, and even with z-index
applied to the <div>
, it doesn't work?