-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsticky.html
121 lines (105 loc) · 2.39 KB
/
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
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
<script type="text/javascript">
$(function() {
<!-- m = document.getElementById -->
m = document.getElementById('main')
c = document.getElementById('content')
m.onscroll = function() {
myFunction()
};
const myFunction = () => {
h = $('#main').scrollTop()
$('#co').text(h)
h >= window.innerHeight && h < window.innerHeight * 2 ?
$('.header').addClass('font-black') :
$('.header').removeClass('font-black')
}
})
</script>
<style>
html,
body,
.main {
width: 100%;
height: 100%;
/* background: #2f2f2f; */
font-size: 22px;
overflow: hidden;
margin: 0;
}
.main {
overflow: auto;
}
.content-wrapper {
width: 100%;
}
.content {
height: calc(300vh);
background: #2f2f2f;
flex: 1;
}
.header {
flex: 1;
height: 100px;
width: 100%;
position: fixed;
box-shadow: 0 0 2px 0 #fff inset;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 2em;
letter-spacing: 5px;
transition: .5s;
text-shadow: 0 0 5px #F0F0FB;
}
.font-black {
color: #000;
}
.section {
width: 100%;
height: 100vh;
box-shadow: 0 0 0 2px #fff inset;
}
.s2 {
background: #ddd;
}
.s3 {
background: #222;
display: flex;
justify-content: center;
align-items: center;
}
.s3 a {
text-decoration: none;
font-size: 2em;
color: #ddd;
text-shadow: 0 0 5px #F0F0FB;
}
</style>
</head>
<body>
<div id="main" class="main">
<div class="content-wrapper">
<div class="header">
<span>Header-color-Demo, calculate content-offset: </span>
<span id='co'>0</span>px
</div>
<div id="content" class="content">
<div class="section s1">
</div>
<div class="section s2">
</div>
<div class="section s3">
<a href="./zoomfade.html">Go Slide Demo</a>
</div>
</div>
</div>
</div>
</body>
</html>