-
Notifications
You must be signed in to change notification settings - Fork 0
/
$+$ Without jQuery.html
106 lines (98 loc) · 2.41 KB
/
$+$ Without jQuery.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scroll Down/Up - Add/Remove Class</title>
<style>
body {
margin: 0;
padding: 0;
}
nav {
height: 100px;
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #cb9857;
transition: 1s;
}
nav.scrollNav {
height: 60px;
background-color: #02846c;
}
img {
height: auto;
max-width: 100%;
}
.content {
text-align: center;
}
.nav-content {
padding: 0 100px;
}
img.logo {
height: 150px;
background: #cb9857;
padding: 20px;
transition: 1s;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
}
nav.scrollNav img.logo {
height: 40px;
padding: 10px;
background: transparent;
}
</style>
</head>
<body>
<nav id="navbar">
<div class="nav-content">
<img src="logo.png" class="logo" alt="">
</div>
</nav>
<div class="content">
<img src="image.jpg" alt="">
<h1>Content Start</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content</h1>
<h1>Content End</h1>
<!-- <img src="web-site-screenshot.png" alt="">-->
</div>
<script>
window.onscroll = function() {
var nav = document.getElementById('navbar');
if (window.pageYOffset > 500) {
nav.classList.add("scrollNav");
} else {
nav.classList.remove("scrollNav");
}
}
</script>
</body></html>