動效

滾動類型scroll-snap-type

Setting how strictly snap points are enforced on the scroll container.

Overview

ClassDeclarations
snap-xscroll-snap-type: x;
snap-yscroll-snap-type: y;
snap-bothscroll-snap-type: both;
snap-blockscroll-snap-type: block;
snap-inlinescroll-snap-type: inline;
scroll-snap-type:x|mandatoryscroll-snap-type: x mandatory;
scroll-snap-type:y|proximityscroll-snap-type: y proximity;
scroll-snap-type:both|mandatoryscroll-snap-type: both mandatory;
scroll-snap-type:nonescroll-snap-type: none;
scroll-snap-type:<value>scroll-snap-type: <value>;

Examples

Snap on the horizontal axis

Use snap-x on a horizontal scroll container. Add snap alignment to the children.

<div class="overflow-x:auto snap-x">    <article class="snap-start">One</article></div>
Generated CSS
@layer utilities {    .snap-x {        scroll-snap-type: x    }}

Require a snap point

Use scroll-snap-type:*|mandatory when the container must settle on a snap point after scrolling.

<div class="overflow-y:auto scroll-snap-type:y|mandatory">    <section class="snap-start">Step</section></div>

Allow nearby snap points

Use proximity when snapping should help alignment without taking over every scroll gesture.

<div class="overflow-x:auto scroll-snap-type:x|proximity">    ...</div>

Apply conditionally

Apply styles based on different states using selectors and conditional queries.

<div class="snap-x scroll-snap-type:y|mandatory@sm scroll-snap-type:none@print">...</div>

  • Master UI


© 2026 Aoyue Design LLC.MIT License
Trademark Policy