CSS / stacking context / overlay

Review CSS stacking contexts and overlays

Review overlap causes that z-index alone cannot fix with fixed cases. This guide does not fetch a real DOM or external CSS.

Stacking-context matrix

Separate the context trigger from the context containing the overlay.

CaseContext triggerOverlay positionReview point
root-contextrootsame rootidentify the base context
position-z-indexposition + z-indexlocal contextcompare within the parent context
opacity-contextopacity < 1inside opacity elementcomparison range changes
transform-contexttransforminside transformed elementidentify the new context
nested-context-boundarynested contextcannot cross parentchild z-index cannot reverse it alone

Review order

  1. Identify the contexts of the overlay and covered element.
  2. Find opacity, transform and z-index context triggers.
  3. Do not compare a child z-index outside its parent context.
  4. Review the real DOM and browser rendering separately.

Fixed cases only. No real site, external CSS or user CSS is handled.

Save fixed material