CSS Position Sticky Not Working? Check What Actually Scrolls

At a glance
Set top: 0 or inset-block-start: 0, then inspect the ancestors for overflow: hidden, auto, or scroll. If an ancestor captures sticky positioning, fix that wrapper or make it the intended scroll container. Check that the sticky element has room to move inside its containing block.
A table of contents scrolls away with the article even though DevTools shows position: sticky. Before changing its height or adding a larger z-index, check what actually scrolls. The browser can use a wrapper as the sticky reference while the reader is scrolling the page.
Check the inset first
For a header that should pin to the top, check that the computed style has top: 0 or inset-block-start: 0. If there is a fixed navigation bar above it, use an offset equal to the space that bar occupies. With both vertical insets set to auto, sticky behaves like relative positioning on that axis.
Reproduce the overflow wrapper bug
Paste this into an empty HTML file and scroll the page:
<style>
.article-shell { overflow: hidden; }
.section-nav {
position: sticky;
top: 0;
background: white;
padding: 1rem;
}
.article-body { min-height: 160vh; }
</style>
<section class="article-shell">
<nav class="section-nav" aria-label="Article navigation">
<a href="#notes">Jump to notes</a>
</nav>
<div class="article-body">Article content</div>
<p id="notes">End of the article</p>
</section>
The wrapper grows with the content. The document scrolls, but the wrapper's overflow: hidden makes it a scroll container for sticky positioning. In DevTools, turn off the wrapper's overflow rule. On the next scroll, the nav should pin at the top until it reaches the bottom of the section. A high z-index only changes painting order and has no effect on which ancestor sticky uses.
If the wrapper only needs to crop decorative overflow, try overflow: clip. It clips without creating a scroll container. Check keyboard focus and any code that previously scrolled the wrapper programmatically before keeping the change. If the wrapper is supposed to scroll independently, give it a bounded height, set overflow: auto, and scroll inside it to verify the sticky behavior.
Find the rule on a real page
Select the sticky element in DevTools and walk up through its parents. Check both computed overflow-x and overflow-y. A wrapper with overflow-x: hidden can compute to overflow-y: auto, even if the source CSS leaves the vertical axis alone. Toggle the rule on the first relevant ancestor and retry the same scroll.
If overflow is correct, compare the sticky element's height with the space in its containing block. In a two-column grid with a long article, a stretched sidebar can fill the entire row and leave no travel distance. If the sidebar itself is sticky, try align-self: start. If a child inside the sidebar is sticky, inspect the sidebar's height before adjusting alignment.
Verify the fix
- Scroll the intended area from above the sticky element to the end of its section. The element should pin at the expected offset and leave the viewport with its section.
- Repeat at a narrow viewport and with browser zoom. Check that a pinned bar leaves enough room to read and reach the content below it.
- If the wrapper was clipping an element that made the page scroll sideways, track down that element. A long label in a flex row may need the flex item overflow fix.
References
Try our QR Code Generator
Create clean, scannable QR codes for testing websites, URLs, and client handoffs.

Ukasha Mart Editorial
Software Developer & Digital Tools Creator
Founder of Ukasha Mart. Building free, accessible browser-based utilities and writing in-depth tutorials on modern technology, freelancing, and practical online work.
Explore Further