CSS Z-index Layering

Z-index controls stacking order of positioned elements.

Preview

Code

<style>
.box1{
position:absolute;
left:20px;
top:20px;
background:#ef4444;
padding:20px;
z-index:1;
}

.box2{
position:absolute;
left:40px;
top:40px;
background:#2563eb;
padding:20px;
z-index:2;
color:white;
}
</style>

<div class="box1">Layer 1</div>
<div class="box2">Layer 2</div>

More CSS Position Examples (9)