--- title: overflow-anchor slug: Web/CSS/overflow-anchor tags: - CSS - CSS Scroll Anchoring translation_of: Web/CSS/overflow-anchor ---
overflow-anchor CSS 属性提供一种退出浏览器滚动锚定行为的方法,该行为会调整滚动位置以最大程度地减少内容偏移。
默认情况下,在任何支持滚动锚定行为的浏览器中都将其启用。因此,仅当您在文档或文档的一部分中遇到滚动锚定问题并且需要关闭行为时,才通常需要更改此属性的值。
/* Keyword values */ overflow-anchor: auto; overflow-anchor: none; /* Global values */ overflow-anchor: inherit; overflow-anchor: initial; overflow-anchor: unset;
autononeTo prevent scroll anchoring in a document, use the overflow-anchor property.
body {
overflow-anchor: none;
}
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('CSS Scroll Anchoring', '#propdef-overflow-anchor', 'overflow-anchor')}} | {{Spec2('CSS Scroll Anchoring')}} | Initial definition. |
{{cssinfo}}
{{Compat("css.properties.overflow-anchor")}}