-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll-state-snapped.html
More file actions
98 lines (85 loc) · 2.03 KB
/
Copy pathscroll-state-snapped.html
File metadata and controls
98 lines (85 loc) · 2.03 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
<style>
html,
body {
width: 100%;
height: 100%;
}
html {
overflow: hidden;
}
body {
margin: 0;
overflow: auto;
}
body {
scroll-snap-type: y mandatory;
}
.ScrollSnap-item {
scroll-snap-align: center;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-size: 50vh;
text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.3);
container-type: scroll-state; /* 追記 */
}
/* 追記 */
.ScrollSnap-item > span {
scale: 1.5;
opacity: 0;
transition: all 2s 0.5s; /* 0.5s遅らせて2sかけて変化する */
}
@container scroll-state(snapped: y) {
.ScrollSnap-item > span {
opacity: 1;
scale: 1;
}
}
.ScrollSnap-item:nth-child(1) {
background-color: floralwhite;
}
.ScrollSnap-item:nth-child(2) {
background-color: deepskyblue;
}
.ScrollSnap-item:nth-child(3) {
background-color: yellowgreen;
}
.ScrollSnap-item:nth-child(4) {
background-color: tomato;
}
.ScrollSnap-item:nth-child(5) {
background-color: darkslategray;
}
</style>
<style>
@supports not (container-type: scroll-state) {
body::before {
/* 日本語で */
content: "お使いのブラウザは、scroll-stateのコンテナクエリーをサポートしていません。";
position: fixed;
top: 0;
left: 0;
width: 100%;
background: black;
color: white;
text-align: center;
padding: 10px;
}
}
</style>
</head>
<body>
<div class="ScrollSnap-item"><span>1</span></div>
<div class="ScrollSnap-item"><span>2</span></div>
<div class="ScrollSnap-item"><span>3</span></div>
<div class="ScrollSnap-item"><span>4</span></div>
<div class="ScrollSnap-item"><span>5</span></div>
</body>
</html>