A “new direction” in the struggle against rightward scrolling

An element carelessly dropped past the right edge of the browser window can leave you with a horizontal scrollbar. Sliding menus and similar components are typical culprits. The usual remedy is overflow-x: hidden; on the body, but it has a habit of wrecking things like position: sticky;.

Push an element off the left edge instead, and no scrollbar appears. That behavior is a form of “data loss,” and it comes down to the page’s direction. Under RTL, the situation flips: the left edge produces the overflow and the right edge stays quiet.

Emerson Loustau builds on that idea to address the problem. The author admits to being too nervous to touch direction this way, given uncertainty about side effects. Still, the approach has one clear upside: it doesn’t break position: sticky;.

Direct Link →