← Binderdex dev log

overflow-x: hidden eats your sticky elements

#web#design#product

A stack of five slides held by a single white pin, the front slide outlined in amber, while one coral-outlined slide has slipped away from its empty dashed pin at the lower left

My feature deck pinned perfectly in the devtools viewport and never once in a real browsing session. Six full-viewport slides were meant to pin as you scroll, each riding up over the last. The whole deck scrolled past like a static page, with no errors and no warnings.

The deck is the feature section on the landing page of Binderdex, my Pokémon card collection and price app. It walks a visitor through the app's features one full-screen slide at a time.

One line on the wrapper

The cause was a single declaration on the <main> wrapper of that landing page. It reads like a harmless guard against sideways scroll:

/* this creates a scroll container */
overflow-x: hidden;

overflow-x: hidden does more than clip horizontal overflow. It turns the element into a scroll container, and position: sticky sticks relative to its nearest scroll-container ancestor. My slides were sticking to <main> instead of the viewport. Since <main> scrolls with the page, nothing visibly pinned.

The previous version of the deck never hit this. It animated with transforms from GSAP, an animation library, which work inside any container. The new deck depends on the scroll-container hierarchy, so it walked straight into the trap.

clip does the job without the side effect

The fix is one property swap. It keeps the clipping and removes the scroll container:

/* clips overflow, creates no scroll container */
overflow-x: clip;

overflow-x: clip clips decorative overflow identically but doesn't establish a scroll container. All six slides came alive on that one change.

Check every ancestor first

When sticky silently does nothing, walk up the tree and check every ancestor for overflow: hidden. It's almost always the answer, and it took me longer to find than I'd like to admit. If the rule only exists to hide horizontal overflow, clip is the replacement.

This is the build log for Binderdex (www.binderdex.com) · All entries · Weekly essays