I can't wrap my head around the concept of z-index. For some reason the gray box appears at the very bottom. Then comes the black box and on top of them, the red box. It should be precisely the other way around. Thx for any help!
HTML:
<div id="gray-box">
<div id="black-box"><div>
<div id="red-box"></div>
</div>
CSS:
#gray-box {
position: relative;
z-index: 2;
background-color: gray;
width: 100%;
height: 4rem;
}
#black-box {
position: relative;
z-index: 1;
background-color: black;
width: 20rem;
height: 4rem;
}
#red-box {
position: relative;
z-index: 0;
background-color: red;
width: 20rem;
height: 4rem;
}