Stacking Context

When?

Z-index and the stacking context are created when:

  1. Items set to a position to be set to fixed, sticky, absolute or relative first for the z-index to work OR if a transform or opacity of less than 1 is applied
  2. Nesting if an element is contained within a containing element it cannot be outside of it’s containing elements position.
  3. Using transform or opacity (with a value below 1) can change an elements stacking context, by moving it up towards the top.
  4. Child elements of a flexbox or grid container where the z-index is other than auto.
  5. An element that has its mix-blend-mode set to other than normal.

Video

  1. MDN article