overflow-anchor CSS property provides a way to opt out of the browser's scroll anchoring behavior, which adjusts scroll position to minimize content shifts.

Scroll anchoring behavior is enabled by default in any browser that supports it. Therefore, changing the value of this property is typically only required if you are experiencing problems with scroll anchoring in a document or part of a document and need to turn the behavior off.

句法

/* Keyword values */
overflow-anchor: auto;
overflow-anchor: none;
/* Global values */
overflow-anchor: inherit;
overflow-anchor: initial;
overflow-anchor: unset;
					

auto

The element becomes a potential anchor when adjusting scroll position.

none

The element won't be selected as a potential anchor.

形式定义

初始值 auto
适用于 所有元素
继承 no
计算值 如指定
动画类型 discrete

形式句法

auto | none
					

范例

Prevent scroll anchoring

To prevent scroll anchoring in a document, use the overflow-anchor 特性。

* {
  overflow-anchor: none;
}
					

规范

规范 状态 注释
CSS Scroll Anchoring Module Level 1
The definition of 'overflow-anchor' in that specification.
编者草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
overflow-anchor Chrome 完整支持 56 Edge 完整支持 79 Firefox 完整支持 66 IE 不支持 No Opera 完整支持 43 Safari 不支持 No WebView Android 完整支持 56 Chrome Android 完整支持 56 Firefox Android 不支持 No Opera Android 完整支持 43 Safari iOS 不支持 No Samsung Internet Android 完整支持 6.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Scroll Anchoring
  4. 特性
    1. overflow-anchor