Sphere
Log in Join
☆ 15

position sticky does nothing inside overflow hidden

I have a sticky sidebar (position: sticky; top: 16px) inside a main container. The container has overflow-x: hidden to stop horizontal scrolling from a wide table. Now the sidebar does not stick at all, it just scrolls away. If I remove overflow-x: hidden sticky works but the page gets a horizontal scrollbar. Chrome 126. Why do these two fight? This one has bitten me more than once.

⚑ Report

4 replies

☆ 0
G graf ·2026-10-20#1

Any overflow value other than visible makes that element the scroll container for sticky descendants. overflow-x: hidden implies overflow-y: auto per spec when one axis is non-visible, so your sidebar is sticking relative to that container, which itself is not scrolling. Hence no visible stick.

⚑ Report
☆ 0
A ansible ·2026-10-27#2

That is brutal but it makes sense. I moved the overflow-x: hidden off the parent that contains the sidebar and applied it only to the table wrapper. Now the sticky ancestor is the page again and everything behaves. Annoying that one property on an ancestor does that.

⚑ Report
☆ 0
M moon ·2026-10-29#3

overflow-x: clip is the newer alternative that does not force the other axis to auto the same way. Browser support is decent now, Chrome 90+, Firefox 81+, Safari 16+. If you can use clip instead of hidden you keep sticky working.

⚑ Report
☆ 0
R rust60 ·2026-10-30#4

Quick diagnostic: when sticky does not work, walk up the DOM and check every ancestor overflow value. 9 times out of 10 there is an overflow: hidden or auto you forgot about. DevTools computed styles makes this fast. The spec is technically right, just not helpful when you are staring at a broken layout.

⚑ Report
Log in to reply.