Guides › HTML / PHP sites › Forms, plugins & updates

CSS: z-index Not Working: Stacking Contexts Explained

Stacking.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Forms, plugins and checkout

z-index only works on positioned elements, and an element can never rise above a stacking context it sits inside. Most failures come from one of those two rules.

1Check the position2Find the stacking context3Compare siblings4Move the element5Remove the culprit6Use sensible values7TestFixed? Test the site. If not, get help.
The steps in order. Work down the list and stop when the problem is solved.

Step 1: Check the position

Illustration for Step 1: Check the position

z-index needs position set to relative, absolute, fixed or sticky (or the element to be a flex or grid item).

Step 2: Find the stacking context

Illustration for Step 2: Find the stacking context

Right-click, Inspect and look at the parents. A parent with transform, opacity below 1, filter or its own z-index creates a context.

Step 3: Compare siblings

Illustration for Step 3: Compare siblings

An element is only compared with others inside the same context. A huge z-index inside a low context still loses.

Step 4: Move the element

Illustration for Step 4: Move the element

Move the overlay to a higher level, for example directly under the body.

Step 5: Remove the culprit

Illustration for Step 5: Remove the culprit

Remove an unnecessary transform or opacity from the parent.

Step 6: Use sensible values

Illustration for Step 6: Use sensible values

Use small scales such as 10, 100, 1000 rather than 99999.

Step 7: Test

Illustration for Step 7: Test

Check desktop and mobile.

Still stuck?

If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-22.