overscroll-behavior
Scroll chaining
When a scroller reaches its end and the gesture continues, the scroll passes to the next scrollable ancestor — usually the page. That hand-off is scroll chaining, and overscroll-behavior decides whether it happens. contain stops the chain but keeps the local bounce; none stops both.
Scroll the bordered panel to its end and keep going. With auto the outer frame takes over; with contain or none it stays put.
Use it for
- Drawers, chat panels, and dropdown lists: reaching the end should not start scrolling the page behind them.
- Modal bodies, so a long dialog does not drag the document underneath.
- overscroll-behavior-x on a horizontally panning canvas or carousel, so a sideways swipe does not trigger the browser’s back navigation.
- overscroll-behavior-y: contain on the root to turn off pull-to-refresh in an app-like page.
Watch for
- It only acts on an element that is actually a scroll container. On a box whose content fits, there is nothing to contain, and the wheel still scrolls the page.
- It does not lock the page. The page still scrolls when the pointer is outside the contained element — that job belongs to a scroll lock.
- Set on body it may do nothing: the viewport takes the value from the root element, so put it on html.
.drawer { overflow-y: auto; overscroll-behavior: contain; }
.canvas { overscroll-behavior-x: none; } /* no swipe-back mid-pan */
html { overscroll-behavior-y: contain; } /* no pull-to-refresh */