π What Is overscroll-behavior-inline?
The overscroll-behavior-inline property controls what happens when a user scrolls **past the boundary of a scrollable container** along theinline axis.
The inline axis depends on writing mode:
- β‘ Horizontal writing (English): inline = left β right
- β¬ Vertical writing (Japanese/Chinese): inline = top β bottom
Note
β Prevents scroll chaining between nested elements
β Useful for horizontal carousels, sliders, or vertical-writing UIs
π¦ Syntax
Syntax
overscroll-behavior-inline: auto | contain | none;| Value | Description |
|---|---|
| auto | Default. Allows scroll chaining and browser overscroll effects. |
| contain | Prevents scroll chaining along inline direction but keeps browser glow/bounce effects. |
| none | Prevents scroll chaining AND disables browser overscroll effects. |
π Understanding Inline Direction
Writing-mode logic
/* Horizontal layout (default) */
writing-mode: horizontal-tb;
// inline = x-axis (left β right)
/* Vertical layout */
writing-mode: vertical-rl;
// inline = y-axis (top β bottom)This makes overscroll-behavior-inline extremely useful for multilingual websites.
π 1. Prevent Horizontal Scroll Chaining in Carousels
Carousel example
.carousel {
overflow-x: auto;
overscroll-behavior-inline: contain;
}Prevents the page from scrolling horizontally when the carousel reaches the end.
π 2. Disable Inline Overscroll Completely
Fully block overscroll
.slider {
overflow-x: scroll;
overscroll-behavior-inline: none;
}Stops both scroll chaining AND browser bounce effects.
π 3. Vertical Writing Mode Example
Vertical writing overscroll
.vertical-section {
writing-mode: vertical-rl;
overflow-y: auto; /* inline direction now vertical */
overscroll-behavior-inline: contain;
}Here the inline axis is vertical, so it prevents upward/downward scroll chaining.
π 4. Horizontal Scrollable Navigation
Nav scroller
.nav-scroller {
display: flex;
overflow-x: auto;
overscroll-behavior-inline: contain;
}Stops the page from shifting when swiping through the nav list.
π 5. Chat List or Message Pane (RTL Friendly)
RTL messaging UI
.messages {
direction: rtl;
overflow-x: auto;
overscroll-behavior-inline: contain;
}Works naturally for RTL conversations without extra configuration.
π§ͺ Real-World Use Cases
1οΈβ£ Horizontal Image Gallery
Image gallery
.image-gallery {
overflow-x: scroll;
overscroll-behavior-inline: contain;
}2οΈβ£ Prevent Outer Container Scrolling
Nested scroll area
.inner {
overflow-x: auto;
overscroll-behavior-inline: none;
}Ensures the scroll stays inside the element.
3οΈβ£ App-Like UI Panels
Mobile app UI
.app-panel {
overscroll-behavior-inline: none;
}Helps create stable, gesture-safe mobile layouts.
β οΈ Common Mistakes
- β Applying inline overscroll on non-scrollable elements
- β Expecting it to control vertical scroll (use block direction for that)
- β Forgetting writing-mode affects inline axis
- β Using contain expecting bounce/pull-to-refresh to be disabled (use none)
Note
π₯ Summary
overscroll-behavior-inline controls how an element behaves when scrolling past its inline boundary. It prevents scroll chaining and can disable overscroll effects entirely. It's the logical, writing-modeβfriendly version of overscroll-behavior-x.
Learn more βMDN Docs π