Z-Index: only works if the element you are trying to style has a non-static position /a defined position
.red, .yellow, .blue{
height: 200px;
width: 200px;
border: 1px solid fuchsia;
position: absolute;
}
.red{
background-color: red;
z-index: 1;
}
.yellow{
background-color: yellow;
top: 40px;
left: 40px;
}
.blue{
background-color: blue;
z-index: -1;
top: 80px;
left: 80px;
}