z-index and Stacking
z-index sets stack order for positioned elements. Higher numbers are in front. Stacking contexts created by opacity, transform or position limit how z-index compares.
Example
<style>
.a, .b { position: absolute; width: 80px; height: 50px } .a { background: #14b8a6; z-index: 2; left: 10px; top: 10px } .b { background: #f59e0b; z-index: 1; left: 40px; top: 25px } .w { position: relative; height: 90px }
</style>
<div class="w"><div class="a">front</div><div class="b">back</div></div>Exercise
Bring to the front.
z-index: ;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.