-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll-snap-type.html
More file actions
57 lines (56 loc) · 2.79 KB
/
Copy pathscroll-snap-type.html
File metadata and controls
57 lines (56 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<!-- 문서 타입 선언: HTML5 -->
<html lang="ko">
<!-- 문서 언어: 한국어 -->
<head>
<meta charset="utf-8">
<!-- 문자 인코딩: UTF-8 -->
<title>scroll-snap-type - 스크롤 컨테이너에서 스냅 포인트의 방향과 엄격도를 설정합니다</title>
<!--
[시각 효과] scroll-snap-type
설명: 스크롤 컨테이너에서 스냅 포인트의 방향과 엄격도를 설정합니다
구문: scroll-snap-type: none | [ x | y | block | inline | both ] [ mandatory | proximity ]?
팁: mandatory는 항상 스냅 포인트에 멈춤, proximity는 가까울 때만 스냅. 캐러셀/슬라이더에 JS 없이 구현 가능.
-->
<style>
/* .snap-container: 가로 강제 스냅 캐러셀 */
.snap-container {
scroll-snap-type: x mandatory; /* 가로(x) 방향, mandatory(항상 스냅) - JS 없이 캐러셀 구현 */
display: flex; /* 가로 배치 */
overflow-x: auto; /* 가로 스크롤 */
gap: 0; /* 간격 0 - 카드가 화면을 꽉 채움 */
border-radius: 12px; /* 모서리 둥글게 */
width: 220px; /* 너비 220px */
margin: 20px auto; /* 위아래 20px, 가로 중앙 */
scroll-behavior: smooth; /* 부드러운 스크롤 - 스냅 이동 시 자연스럽게 */
}
/* .snap-item: 스냅 카드 */
.snap-item {
scroll-snap-align: start; /* 시작점 스냅 정렬 */
min-width: 220px; /* 최소 너비 220px - 컨테이너 가득 */
height: 120px; /* 높이 120px */
display: flex; /* 플렉스 */
align-items: center; /* 세로 중앙 */
justify-content: center; /* 가로 중앙 */
color: white; /* 흰 글자 */
font-size: 36px; /* 큰 숫자 36px */
font-weight: bold; /* 굵게 */
flex-shrink: 0; /* 축소 방지 */
}
</style>
</head>
<body>
<!-- scroll-snap-type 가로 캐러셀 데모 -->
<div class="snap-container">
<!-- 가로 강제 스냅 컨테이너 -->
<div class="snap-item" style="background:#3b82f6">1</div>
<!-- 파랑 슬라이드 1 -->
<div class="snap-item" style="background:#8b5cf6">2</div>
<!-- 보라 슬라이드 2 -->
<div class="snap-item" style="background:#f43f5e">3</div>
<!-- 핑크 슬라이드 3 -->
<div class="snap-item" style="background:#10b981">4</div>
<!-- 초록 슬라이드 4 -->
</div>
</body>
</html>