property

Overflow anchor — CSS reference

Opts an element and eligible descendants out of anchor selection for the relevant scrolling box. Setting none on the scroller disables anchoring for that scrolling box; nested scrolling boxes have their own anchoring. Use it selectively rather than disabling all page stability.

Formal Syntax & Structure

css syntaxcss
overflow-anchor: none;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>overflow-anchor</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#s{height:100px;width:200px;overflow:auto}#before{height:200px;overflow-anchor:none}#a{height:60px;overflow-anchor:auto}#after{height:400px}#s{overflow-anchor:none}</style><body><div id="s" tabindex="0" aria-label="Scroll anchoring example"><div id="before"></div><div id="a">Visible anchor</div><div id="after"></div></div><button id="go">Insert content above</button><script>document.querySelector("#go").onclick=()=>document.querySelector("#before").style.height="260px";document.querySelector("#s").scrollTop=200;</script></body></html>
CSS Reference