QuizNot attempted
Stacking contexts
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- The modal is inside a parent that creates its own stacking context (e.g.
transform,opacity < 1, orposition+z-index), and that parent sits below the header
z-indexonly competes within the same stacking context- an ancestor with
transform,opacity < 1,filter, or positioned +z-indextraps its children at the ancestor's own level, so 9999 inside a low context still loses to 10 outside. - Not flex items only: z-index works on positioned elements and on flex/grid items.
- Not a max of 1000: there is no such cap (it is a 32-bit integer).
- Not sticky: sticky is just another positioned value and doesn't beat a higher z-index on its own.
- Fix: portal the modal to
<body>or use the<dialog>top layer.