-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav-bar.html
81 lines (72 loc) · 2.43 KB
/
nav-bar.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
<html>
<head>
<style>
/*DONT COPY THIS: ESSENTIAL IN EVERY <STYLE> HEADING*/
* {
margin: 0;
padding: 0;
}
#nav-bar {
width: 100%;
height: 10%;
position: fixed;
display: flex;
background-color: transparent;
transition: ease 0.5s;
font-family: Titillium Web;
}
#nav-bar ul {
list-style-type: none;
margin: auto;
padding: 0;
}
#nav-bar li {
display: inline-block;
}
#nav-bar a {
color: black;
text-decoration: none;
margin-left: 50px;
top: 5%;
}
.underline {
border-bottom: black 1px solid;
padding-bottom: 5px;
}
/*HERE*/
</style>
</head>
<body>
<!--COPY DIV "nav-bar" AND "<script>" BELOW-->
<div id="nav-bar">
<ul>
<li><a href="index.html" class="underline">Home</a></li>
<li><a href="about.html" class="nav-item">About The Products</a></li>
<li><a href="store.html" class="nav-item">Store</a></li>
<li><a href="FAQ.html" class="nav-item">FAQ</a></li>
<li><a href="AboutCompany.html" class="nav-item">About Us</a></li>
<li><a href="Contact.html" class="underline">Contact Us</a></li>
</ul>
</div>
<script>
window.onscroll = function() {
const nav = document.getElementById('nav-bar');
if (window.pageYOffset > 750) {
nav.style.backgroundColor = 'white';
} else {
nav.style.backgroundColor = 'transparent';
}
}
var elements = document.getElementsByClassName("nav-item");
for (i = 0; i < elements.length; i++) {
elements[i].addEventListener('mouseenter', function(e) {
this.classList.add('underline');
})
elements[i].addEventListener("mouseleave", function(e) {
this.classList.remove('underline');
})
}
</script>
<!--HERE-->
</body>
</html>