stacking context

A group of elements that the browser layers together, so their z-index values only compete with each other and not with the rest of the page.

In more detail

Properties such as transform, filter, opacity below 1 and position with a z-index create a new stacking context. An overlay inside one cannot rise above elements outside it, however high its z-index, which is why overlays are portaled to the body.

Example

That is why React modals are rendered through a portal at the end of the page.

Related terms

Taught in

References