-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsticky.html
More file actions
37 lines (35 loc) · 1.06 KB
/
sticky.html
File metadata and controls
37 lines (35 loc) · 1.06 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./assets/css/sticky.css">
</head>
<body>
<div class="header">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="section color1"></div>
<div class="section color2"></div>
<div class="section color3"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script type="text/javascript">
$(() => {
$(window).scroll( () => {
if($(window).scrollTop() > 0) {
$(".header").addClass("sticky");
} else {
$(".header").removeClass("sticky");
}
});
});
</script>
</body>
</html>