π What Is overscroll-behavior-block?
The overscroll-behavior-block property controls what happens when a user scrolls **past the boundary of a scrollable container** along theblock axis.
The block axis depends on the documentβs writing-mode:
- β‘ Horizontal writing (English): block = vertical scroll (top β bottom)
- β¬ Vertical writing (Japanese/Chinese): block = horizontal scroll (left β right)
Note
β Prevents scroll chaining along block direction
β Essential for modals, sidebars, chat apps, and vertical content layouts
π¦ Syntax
Syntax
overscroll-behavior-block: auto | contain | none;| Value | Description |
|---|---|
| auto | Default. Allows scroll chaining + browser overscroll effects. |
| contain | Prevents scroll chaining along block direction but keeps bounce/glow effects. |
| none | Prevents scroll chaining AND disables browser overscroll effects (e.g., pull-to-refresh). |
π 1. Prevent Page From Scrolling When a Panel Reaches the Top/Bottom
Scrollable panel
.panel {
overflow-y: auto;
overscroll-behavior-block: contain;
}When the user scrolls to the top or bottom of the panel, the page behind it will NOT scroll.
π 2. Disable Vertical Overscroll Completely
Disable bounce/pull-to-refresh
body {
overscroll-behavior-block: none;
}Prevents bouncing, glow effects, and pull-to-refresh gestures. Common in fullscreen web apps.
π 3. Vertical Scroll Lock Inside Modals
Modal content
.modal-content {
overflow-y: auto;
overscroll-behavior-block: contain;
}π 4. Vertical Writing Mode Example (Block Axis Becomes Horizontal)
Vertical writing overscroll
.vertical-section {
writing-mode: vertical-rl;
overflow-x: auto; /* block axis = inline-left/right? no β block axis flips */
overscroll-behavior-block: contain;
}In vertical writing, **block-axis scrolling is horizontal**. This property will now control horizontal overscroll!
π 5. Prevent Scroll Leaking in Nested Chat Interfaces
Chat message list
.chat-list {
overflow-y: auto;
overscroll-behavior-block: contain;
}Prevents the page from scrolling when reaching top/bottom of chat messages.
π 6. Mobile Browsers β Stop Pull-To-Refresh
No pull-to-refresh
html, body {
overscroll-behavior-block: none;
}Essential for PWAs (Progressive Web Apps) and full-height web apps.
π§ͺ Real-World Use Cases
1οΈβ£ Scrollable Sidebar
Sidebar
.sidebar {
overflow-y: auto;
overscroll-behavior-block: contain;
}2οΈβ£ Long Forms in a Dialog
Long form
.form-wrapper {
overflow-y: scroll;
overscroll-behavior-block: contain;
}3οΈβ£ Sticky Headers Without Scroll Chaining Issues
Sticky header
header {
position: sticky;
top: 0;
overscroll-behavior-block: none;
}β οΈ Common Mistakes
- β Applying it on non-scrollable elements
- β Assuming it stops horizontal scroll (use inline version)
- β Using contain expecting bounce or pull-to-refresh to disappear (use none)
- β Forgetting that block axis changes in vertical writing modes
Note
π₯ Summary
The overscroll-behavior-block property controls block-axis overscroll behavior, preventing scroll chaining and optionally disabling browser overscroll effects. It's the logical, writing-mode-aware version of overscroll-behavior-y.
Learn more βMDN Docs π