z-index is used to control the vertical stacking order of elements (which element appears on top of others).
Only works on elements with a position
value other than static
(e.g., relative
, absolute
, fixed
, or sticky
).
element { position: absolute; z-index: 2; }
The green box has a higher z-index
and overlaps the red box.
z-index
value = element appears on top.z-index
, the one written later in the HTML appears on top.Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!