concept
Snap position — CSS reference
A snap position is a reachable scroll offset that satisfies the snap area alignment. In this example items begin at 100px intervals and the requested offset 175px settles on 200px.
Formal Syntax & Structure
css syntaxcss
scroll-snap-type: x mandatory;Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Snap position</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#s{width:100px;height:90px;overflow-x:auto;scroll-snap-type:x mandatory}#strip{display:flex;width:400px}#strip>div{flex:0 0 100px;height:65px;box-sizing:border-box;scroll-snap-align:start;border:1px solid #777;padding:0}</style><body><div id="s" tabindex="0" aria-label="Snap carousel"><div id="strip"><div>One</div><div id="a">Two</div><div>Three</div><div>Four</div></div></div><button id="go">Scroll toward item three</button><script>document.querySelector("#go").onclick=()=>document.querySelector("#s").scrollTo({left:175,behavior:"instant"});</script></body></html>