Stacking Contexts and z-index — Concept Check
Questions on Stacking Contexts and z-index. z-index only compares siblings within the same stacking context. That single rule explains why a z-index of 9999 can still render behind something set to 1.
Questions in this quiz
7 questions on Stacking Contexts and z-index — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer sets a modal's z-index to 9999, but it still appears behind another element with z-index 2. What is likely causing this?
- AThe modal's position property is incorrect.
- BThe modal is within a stacking context with a lower z-index.
- CThe z-index value is too high to be effective.
- DThe other element is using a higher CSS specificity.
2.Which property can unexpectedly create a new stacking context, affecting z-index behavior?
- Aopacity: 0.99
- Bposition: fixed
- Cdisplay: block
- Dmargin: auto
3.A card with a hover transform clips its own dropdown. What could be causing this issue?
- AThe card's height is too small.
- BThe card's width is too narrow.
- CThe dropdown has a lower z-index than the card.
- DThe transform creates a new stacking context.
4.What is the correct order of rendering within a single stacking context?
- ABackground, inline content, floats, block boxes, z-index 0, positive z-index
- BBackground, positive z-index, block boxes, floats, inline content, z-index 0
- CBackground, z-index 0, block boxes, floats, inline content, positive z-index
- DBackground, block boxes, floats, inline content, z-index 0, positive z-index
5.A developer uses `transform: translateZ(0)` on an element. What effect does this have?
- AIt creates a new stacking context.
- BIt changes the element's position on the Z-axis.
- CIt reduces the element's opacity.
- DIt increases the element's z-index.
6.Why might a modal with z-index 400 render above a toast with z-index 500?
- AThe toast is not part of the current stacking context.
- BThe modal is in the top layer, which overrides z-index.
- CThe modal is using a higher CSS specificity.
- DThe toast's position property is set to static.
7.When should you use isolation: isolate in CSS?
- ATo prevent elements from overlapping.
- BTo improve the rendering performance of a page.
- CTo deliberately create a stacking context for component isolation.
- DTo increase the z-index of an element.