Frontend · interactive
Stacking contexts and z-index
The modal has z-index 9999 and the header only 10, yet the modal can end up underneath. z-index only competes inside the same stacking context, and some CSS properties quietly create a new one. This is the real browser rendering it.
.header { position: sticky; z-index: 10; }
.card { position: relative; z-index: 1; }
.modal { position: absolute; z-index: 9999; }Header · z-index: 10
.card (stacking context, z 1)
Modal · z-index: 9999
Modal is trapped below the header
The card forms a stacking context. Everything inside it, the modal included, is painted as one layer at the card's level, which is below the header's 10. 9999 only beats siblings inside the card.
Card styles
Step 3 of 4 · read left to right
In production
Tools and technologies
Overlays break the same way in every codebase.
Not tied to one language — use these names when you search docs or design a system.