Menu

overflow: hidden breaks position: sticky. overflow: clip doesn't.
📰

overflow: hidden breaks position: sticky. overflow: clip doesn't.

DEV Community: css·Parsa J·about 2 hours ago
#MMReYVjK
#devtocss#devto#dev#sticky#overflow
Reading 0:00
15s threshold

Someone reports a bug: the "jump to section" bar at the top of a long settings page used to stick to the top of the viewport while you scrolled. Now it doesn't. It just sits there in normal flow like position: sticky was never applied.

You open devtools. The CSS is untouched — position: sticky; top: 0; , same as it's been for months. No typo, no overridden rule, nothing crossed out in the inspector. The element is exactly as sticky as it was yesterday. Except it isn't sticking.

The actual change shipped in a different file entirely: a shared <Card> component picked up overflow: hidden last week, to stop a decorative background image from spilling past its rounded corners. Nobody touched the settings page. Nobody touched the sticky bar. And yet here we are.

The rule nobody reads until it bites them

position: sticky doesn't stick to the viewport by default. It sticks to its nearest scroll container — the closest ancestor whose overflow isn't visible .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.