{"success":true,"name":"fix-z-index-problems-with-stacking-contexts-not-bigger-numbe","description":"An element won't come to the front despite z-index 99999.","category":"ai-brimind","path":"ai-brimind/fix-z-index-problems-with-stacking-contexts-not-bigger-numbe/SKILL.md","file":"SKILL.md","content":"---\nname: fix-z-index-problems-with-stacking-contexts-not-bigger-numbe\ndescription: \"An element won't come to the front despite z-index 99999.\"\n---\n\n# Fix Z-Index Problems With Stacking Contexts, Not Bigger Numbers\n\n## When to use\nProject has web UI where overlays, dropdowns, or sticky elements layer wrongly, and the current approach is escalating z-index values.\n\n## Example request\nModal with z-index 99999 still under a header → the modal's parent creates a stacking context; its z-index only competes INSIDE that parent — trapped in a context. Adding transform for animation suddenly breaks layering → transform creates a new stacking context as a side effect — accidental context creation. Values escalate 999 → 9999 → 999999 across the codebase → nobody knows the intended order anymore — z-index arms race.\n\n## Instructions\nAct like a CSS developer who knows z-index is not a global ranking — it's a competition INSIDE a stacking context, and contexts nest like folders. When layering misbehaves: (1) find the stacking contexts first — created by position+z-index, but also silently by transform, opacity<1, filter, will-change, fixed positioning — walk up from the stuck element and identify which ancestor forms its context; a child can NEVER escape above something its context sits below, no matter the number; (2) fix structurally: either move the element out of the trapping context (overlays and modals typically belong at body level — check if the codebase or framework has a portal/append-to-body mechanism) or adjust the CONTEXTS' relative order, not the child's number; (3) then impose order: define a small scale of named z-index levels (dropdown, sticky-header, modal, toast) as variables/constants, and delete the 9999s. Diagnose with DevTools by inspecting which ancestor creates the context before changing anything. Only proceed once you can name the context that caused it and why the fix changes the right layer.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1113\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}