-
Notifications
You must be signed in to change notification settings - Fork 1
/
responsive-nav.html
110 lines (109 loc) · 3.25 KB
/
responsive-nav.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">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Nav</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
color: white;
}
nav {
display: flex;
justify-content: space-around;
min-height: 8vh;
align-items: center;
background-image: linear-gradient(45deg, rgb(236, 22, 22), rgb(88, 9, 9));
font-size: 1rem;
letter-spacing: 3px;
text-transform: capitalize;
}
.nav-list {
display: flex;
list-style-type: none;
width: 35%;
justify-content: space-evenly;
}
.burger div {
height: 3px;
background-color: white;
width: 25px;
margin: 5px;
}
.burger {
display: none;
}
@media screen and (max-width: 760px) {
.nav-list {
position: absolute;
top: 0px;
height: 100vh;
width: 100vw;
background-image: linear-gradient(45deg, rgb(236, 22, 22), rgb(88, 9, 9));
flex-direction: column;
justify-content: space-evenly;
align-items: center;
transform: translateY(-100%);
transition: 2s;
}
.burger-close {
position: absolute;
top: 1vh;
right: 3vw;
cursor: pointer;
}
.burger-close div {
height: 3px;
background-color: white;
width: 25px;
margin: 5px;
}
.burger {
display: block;
cursor: pointer;
}
}
.slider-down {
transform: translateY(0%);
}
.slider-up {
transform: translateY(-100%);
}
</style>
</head>
<body>
<nav>
<div class="logo">Karan Inc.</div>
<ul class="nav-list">
<li><a href="">Home</a></li>
<li><a href="">Contact</a></li>
<li><a href="">Blog</a></li>
<li><a href="">About</a></li>
<div class="burger-close">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</ul>
<div class="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
</body>
<script>
document.querySelector(".burger").addEventListener("click", function() {
document.querySelector(".nav-list").classList.add("slider-down");
document.querySelector(".nav-list").classList.remove("slider-up");
});
document.querySelector(".burger-close").addEventListener("click", function() {
document.querySelector(".nav-list").classList.add("slider-up");
document.querySelector(".nav-list").classList.remove("slider-down");
});
</script>
</html>