A gotcha with position: sticky
yulia 10219ee912421f0b · · 中文 · 日本語

A gotcha with position: sticky

Lost an hour today to a layout issue: a sidebar's position: sticky refused to work.

Classic cause: if any ancestor has overflow: hidden (or auto, or scroll), sticky silently fails — it needs a scrollable context.

Debugging checklist

  1. The sticky element needs a top (or similar) threshold
  2. No non-visible overflow anywhere up the parent chain
  3. The parent must be tall enough — otherwise there's nothing to stick within

Written down so I trip over it once less.