-
Notifications
You must be signed in to change notification settings - Fork 843
/
Copy pathscroll-padding-sticky.html
110 lines (88 loc) · 2.2 KB
/
scroll-padding-sticky.html
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
99
100
101
102
103
104
105
106
107
108
109
110
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Scroll Snap - scroll-padding sticky header</title>
<link rel="stylesheet" href="../css-cookbook/styles.css">
<style>
.scroller {
border: 4px solid #333;
width: 300px;
}
.scroller section {
min-height: 100%;
padding: 10px;
}
.scroller section:nth-child(odd) {
background-color: #ccc;
}
.scroller h1 {
position: sticky;
top: 0;
min-height: 40px;
background-color: #000;
color: #fff;
margin: 0;
padding: 0;
}
.scroller h2 {
margin: 0;
padding: 0;
}
</style>
<style class="editable">
.scroller {
height: 300px;
overflow-y: scroll;
scroll-snap-type: y proximity;
scroll-padding: 40px;
}
.scroller section {
scroll-snap-align: start;
}
</style>
</head>
<body>
<section class="preview">
<article class="scroller">
<h1>Sticky Heading</h1>
<section>
<h2>Section one</h2>
</section>
<section>
<h2>Section two</h2>
</section>
<section>
<h2>Section three</h2>
</section>
</article>
</section>
<textarea class="playable playable-css" style="height: 170px;">.scroller {
height: 300px;
overflow-y: scroll;
scroll-snap-type: y mandatory;
scroll-padding: 40px;
}
.scroller section {
scroll-snap-align: start;
}</textarea>
<textarea class="playable playable-html" style="height: 230px;">
<article class="scroller">
<h1>Sticky Heading</h1>
<section>
<h2>Section one</h2>
</section>
<section>
<h2>Section two</h2>
</section>
<section>
<h2>Section three</h2>
</section>
</article>
</textarea>
<div class="playable-buttons">
<input id="reset" type="button" value="Reset">
</div>
</body>
<script src="../css-cookbook/playable.js"></script>
</html>