A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
<style>.demo { position: relative; z-index: 10; }</style><main class="demo">Example content</main>
In production, A huge z-index cannot escape an ancestor stacking context that is itself painted below another context. Raising 9999 is not a universal fix. That is the kind of bug that survives visual spot checks because the stylesheet is syntactically valid while the layout contract is wrong.
The useful mental model here is practical: how painting order, stacking contexts, positioned elements, transforms, and isolation affect which surface appears on top. When a rule looks obvious but the browser produces something else, start by identifying which constraint or rendering phase is actually winning.
<style>.demo { transform: translateZ(0); }</style><main class="demo">Example content</main>
Engineering judgment: Prefer small, local z-index scales and create explicit stacking boundaries when a component owns an overlay system.
| Concern | What to inspect | Typical failure |
|---|---|---|
| Core behavior | Z-Index and Stacking Contexts | A huge z-index cannot escape an ancestor stacking context that is itself painted below another context. Raising 9999 is not a universal fix. |
| Production test | Real content and constraints | The rule works only for the demo values |
| Maintenance | Scope and override path | A later fix creates another exception |
The useful mental model here is practical: how painting order, stacking contexts, positioned elements, transforms, and isolation affect which surface appears on top. When a rule looks obvious but the browser produces something else, start by identifying which constraint or rendering phase is actually winning.
<style>.demo { isolation: isolate; }</style><main class="demo">Example content</main>
Isolated component is useful here because it demonstrates z-index and stacking contexts under a concrete input rather than as an abstract property list.
<style>.menu { position: absolute; z-index: 2; }</style><main class="menu">Example content</main>
Local overlay is useful here because it demonstrates z-index and stacking contexts under a concrete input rather than as an abstract property list.
Finish the lesson once you have worked through the material. This awards ★ 20 XP.