z-index
only applies to elements with a position
other than static
, so for example: relative
, absolute
, or fixed
.
div {
width:100px;
height: 100px;
position:relative;
}
.div1 {
background: red;
z-index: 2;
}
.div2 {
background: blue;
margin-top: -15vh;
z-index: 1
}