Understanding `sticky` and its Parent Container

Gotcha: `sticky` in a Short Parent

This element has `sticky top-0`.

This parent container is only h-48 . Since there's no overflow/scroll *within this parent*, the "sticky" element above won't appear to stick relative to the overall page scroll. It sticks only to the top of *this gray box* if this box itself were to scroll.

Observation: The yellow bar will not stick to the top of the browser window as you scroll the main page, because its direct parent (the gray box) is not tall enough to have its own scrollbar that would reveal the sticky behavior.

Correct: `sticky` in a Tall Scrolling Parent

This element has `sticky top-0`.

This parent container is h-96 and has overflow-y-auto . Now, scroll *inside this gray box*.

Content Block A
Content Block B
Content Block C
Content Block D

Observation: The green bar sticks to the top of *this gray box* as you scroll within it.

Correct: `sticky` in an Implicitly Tall Parent (Page Scroll)

Main Page Sticky Header

This uses `sticky top-0` and its parent is the `body` (or a large div wrapping content).

This purple header is sticky to the top of the browser viewport when the page scrolls because its parent (ultimately the body or a main wrapper) is tall enough for the page to scroll.

Extra content to make the whole page scrollable...
Even more content...