Code · Made a little simpler

Z-index Stacking Visualizer

Adjust z-index in nested stacking contexts. Toggle a context trigger, see which layer paints on top, and copy or download the example.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device

Child layer is on top at the overlap. Parent shares the outer stacking context.

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

Z-index Stacking Visualizer: how to use it

  1. Compare the overlapping child and sibling in the starting example. Change either numeric z-index to test their order.
  2. Set a numeric parent z-index or enable Transform parent. Compare the layer on top while keeping the child's value unchanged.
  3. Copy or download stacking-context.html and open it in a browser to inspect the same structure and styles.

Limits and notes

Runs in your browser. Uses positioned layers with z-index values from 0–9,999. The parent also accepts auto. The preview illustrates this fixed tree, document order and the selected transform trigger.

How your privacy works →

Z-index Stacking Visualizer: common questions

Why can a larger child z-index still lose?

When the parent creates a stacking context, the whole parent context is compared with the outer sibling first. The child's number orders layers inside its parent.

Does a transform that moves the parent by zero create a stacking context?

Yes. The checkbox uses translateX(0), which sets a transform other than none without changing the position in this example.

What wins when the two competing layers have the same z-index?

In this positioned example the later sibling paints on top when the competing values are tied.

Guides