HTML & CSS · Middle · Question 28 of 75
What is a stacking context, and why might z-index: 9999 "not work"?
- ✓Correct answer: A group within which
z-indexvalues compare; a child can't rise above its parent's siblings - 2It's a browser limitation:
z-indexvalues above 999 are simply ignored - 3It's the order of elements in the HTML markup, which
z-indexcan't change
Explanation
An element with position + z-index, opacity < 1, transform, filter, isolation: isolate and so on creates its own stacking context. Everything inside it is painted as a single unit relative to its siblings. If a parent with z-index: 1 is below a sibling with z-index: 2, a child with 9999 still ends up below that sibling.