Stacking context

noun

say it: “STAK-ing KON-tekst” /ˈstækɪŋ ˈkɑntɛkst/

A group of layers that stack together as one. z-index only compares elements inside the same group, so a child can never rise above something outside its group.

What is a stacking context?

A stacking context is a group whose layers stack together. z-index only compares elements inside the same group, which is why a huge z-index sometimes doesn't help.

.card { position: relative; z-index: 1; }   /* a new stacking context */
.card .menu { z-index: 9999; }   /* can't rise above elements outside .card */

In a sentence

  • “The menu's z-index of 9999 did nothing, because its card had started a new stacking context.”

Level: Master · More CSS terms at this level

Updated