Menu

1 / 2

position: sticky Does Nothing? Hunt Down the Hidden Overflow

DEV Community: css·Pixel Recruiting LLC·about 12 hours ago
#JE6kSE7D
#devtocss#devto#dev#overflow#sticky
Reading 0:00
15s threshold

You add position: sticky and top: 0 to your header. You scroll. The header scrolls away like nothing happened.

No error in the console. No warning in DevTools. Just a header that won't stick.

This post explains the usual reason, shows a fix you can paste in, and gives you a small script that finds the problem for you.

The problem

Someone posted this in a CSS forum. Here is the gist, in our own words.

They wanted the header on their page to stay at the top while the user scrolled. They added position: sticky . Nothing changed. They had already worked through a popular checklist of "why sticky isn't working": siblings, parent height, z-index, browser support. Still no luck.

The answer that solved it was one line far away from the header: a wrapper higher up the page had overflow: hidden .

Quick version of how sticky works

A sticky element acts like a normal element until you scroll it to a set point.…

Continue reading — create a free account

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