scroll-snap-type
스크롤 스냅을 활성화합니다. sstxm은 수평 캐러셀에, sstym은 수직 페이지 스냅에 사용합니다.
클래스 목록
| 클래스 | CSS | 설명 |
|---|---|---|
sstn | scroll-snap-type: none | 스크롤 스냅 비활성화 |
sstxm | scroll-snap-type: x mandatory | 수평 필수 스냅 |
sstym | scroll-snap-type: y mandatory | 수직 필수 스냅 |
sstbm | scroll-snap-type: both mandatory | 양방향 필수 스냅 |
sstxp | scroll-snap-type: x proximity | 수평 근접 스냅 |
sstyp | scroll-snap-type: y proximity | 수직 근접 스냅 |
sstbp | scroll-snap-type: both proximity | 양방향 근접 스냅 |
사용 예시
scroll-snap-type은 스크롤 컨테이너에 적용하며, 자식 요소에 scroll-snap-align을 함께 사용합니다.
<!-- 수평 캐러셀 -->
<div class="df sstxm oh">
<div class="fs0 w100p ssas">Slide 1</div>
<div class="fs0 w100p ssas">Slide 2</div>
<div class="fs0 w100p ssas">Slide 3</div>
</div>
<!-- 수직 페이지 스냅 -->
<div class="sstym oh h100vh">
<section class="h100vh ssas">Section 1</section>
<section class="h100vh ssas">Section 2</section>
</div>mandatory vs proximity
| 타입 | 동작 |
|---|---|
| mandatory | 스크롤이 끝나면 반드시 스냅 포인트에 정렬됩니다 |
| proximity | 스냅 포인트 근처일 때만 정렬됩니다 |