Generator Tools
CSS Z-Index Manager
Build an organized z-index scale as CSS variables, a Sass map, or a JS object, and diagnose why a z-index is not working with a stacking context checker.
Z-index scale
Order your layers from lowest to highest. Values are spaced so you can slot new layers in later without renumbering everything.
Example: --z-modal
9 layers, range 0 to 800
- 0
--z-base
- 100
--z-dropdown
- 200
--z-sticky
- 300
--z-fixed
- 400
--z-overlay
- 500
--z-modal
- 600
--z-popover
- 700
--z-toast
- 800
--z-tooltip
Higher in the list means higher on the page. The numeric value is derived from the order, so reordering or inserting a layer keeps every value consistent and gap-free.
Layer preview
A visual stack of your first nine layers, lowest at the back. The preview uses its own local stacking order for illustration; your generated values are what matter in real CSS.
:root {
--z-base: 0; /* Default document flow */
--z-dropdown: 100; /* Menus, select popovers */
--z-sticky: 200; /* Sticky headers and bars */
--z-fixed: 300; /* Fixed page chrome */
--z-overlay: 400; /* Modal backdrop / scrim */
--z-modal: 500; /* Dialogs and modals */
--z-popover: 600; /* Popovers and menus over modals */
--z-toast: 700; /* Toasts and notifications */
--z-tooltip: 800; /* Tooltips, always on top */
}Use a layer with z-index: var(--z-modal); instead of a magic number, so every layer references the single source of truth above.
Why is my z-index not working?
A child can never beat the stacking order of an ancestor that forms its own stacking context, no matter how high its z-index is. Toggle the styles on an element below to see whether it creates a new stacking context.
This element does not create a new stacking context.
Descendant z-index values compete in the nearest ancestor stacking context (often the root). The root element always forms the base stacking context.
Selected declarations
/* No context-forming declarations selected. */Quick fixes
- Add isolation: isolate to a parent on purpose when you want to contain its children, instead of fighting it with ever-larger numbers.
- If an overlay must sit above everything, render it at the document root (for example a portal) so no ancestor traps it.
- Watch for a parent with transform, filter, or opacity: 0.99: these silently create a context and are the most common cause of a z-index that looks ignored.
How to use
- Review the default layer scale, then rename, reorder, add, or remove layers so the order matches your project, lowest at the top.
- Set the start value and the step between layers. A larger step, such as 100, leaves room to insert new layers later without renumbering.
- Optionally set a custom property prefix and add a note to each layer; notes become comments in the generated CSS.
- Switch the output between CSS variables, a Sass map, and a JS or TS object, then copy the code into your stylesheet or tokens file.
- Open the stacking context section and toggle on the styles present on a misbehaving element to see whether it creates a new stacking context and why.
- Apply the suggested fixes, for example isolation: isolate or rendering an overlay at the root. Everything runs in your browser with no upload.
About this tool
CSS Z-Index Manager does the two things developers actually search for when z-index gets confusing: it gives you an organized scale to replace magic numbers, and it explains why a z-index that should work is being ignored. The first half is a scale builder. Most projects accumulate z-index values like 1, 10, 100, 999, 9999, and 2147483647 scattered across files with no relationship to each other, and the moment a new layer needs to slot between two existing ones the whole thing gets bumped up by hand. Here you define your layers in order, from the document base up through dropdowns, sticky headers, fixed chrome, overlays, modals, popovers, toasts, and tooltips, and the tool assigns each one a numeric value derived from its position. You choose the starting value and the step between layers, so a step of 100 leaves room to insert a new layer at, say, 250 without touching anything else. Reordering a layer, renaming it, adding one, or removing one keeps every value consistent and gap-free because the numbers come from the order, not from a value you typed. The scale is emitted three ways: as CSS custom properties on :root that you reference with z-index: var(--z-modal), as a Sass map with a small accessor function, and as a typed JavaScript or TypeScript object, so it drops into whatever stack you use. A custom property prefix lets you namespace the variables, and each layer carries an optional note that becomes a comment in the CSS output, turning the file into living documentation of what sits on each layer. The second half is a stacking context diagnostic, and this is the part that fixes the classic z-index: 99999 still does not show on top bug. The cause is almost always a stacking context: a child element can never escape the stacking order of an ancestor that forms its own context, no matter how large the child's z-index is. To a sibling outside that ancestor, the whole subtree stacks as a single unit at the ancestor's level. The catch is that many ordinary CSS declarations create a stacking context without any obvious connection to layering. A positioned element with a z-index does it, which everyone expects, but so does opacity below 1, any transform other than none, a filter, a backdrop-filter, will-change naming a context-forming property, isolation: isolate, mix-blend-mode, clip-path, mask, perspective, contain, and a z-index on a flex or grid child even with no position. The diagnostic lists each of these as a toggle. Switch on the declarations present on your element and the tool tells you live whether it forms a stacking context and, for every active trigger, exactly why, so you can spot the parent with opacity: 0.99 or a transform animation that is quietly trapping your modal. It also copies the selected declarations as a CSS snippet and offers concrete fixes: reach for isolation: isolate when you want to contain children on purpose, render overlays at the document root so no ancestor can trap them, and watch parents using transform, filter, or fractional opacity. Everything is computed in your browser from local state. The layers you define, the values you pick, and the toggles you select are never uploaded, never logged, and never leave your device.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
CSS Transform Generator
Visual transform builder with 2D and 3D functions, live preview, and copy-ready CSS.
Open tool
GeneratorCSS Box Shadow Generator
Layered box-shadow with live preview, opacity, inset, and Tailwind output.
Open tool
DeveloperCSS Variables Extractor
List every --custom property in a stylesheet with usage counts and one-click export.
Open tool
GeneratorCSS Grid Generator
Visual builder for grid-template-columns, rows, gap, alignment, and per-item placement.
Open tool
GeneratorCSS Flexbox Generator
Visual CSS flexbox builder with live preview and copy-ready code.
Open tool