Skip to content

Commit 1768e9d

Browse files
committed
added hamburger animation
1 parent 96ab72b commit 1768e9d

File tree

2 files changed

+94
-5
lines changed

2 files changed

+94
-5
lines changed

_includes/navbar.html

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11

2-
<nav class="navbar navbar-expand-lg navbar-dark">
3-
<div class="d-flex d-none d-sm-block d-md-block d-lg-none">
2+
<nav class="navbar navbar-dark">
3+
<div class="d-flex d-none d-sm-block d-md-block mx-auto">
44
<div class="navbar-header">
55
<a class="navbar-brand" href="/"><img src="/assets/img/logo/logo.png" style="height: 70px; width: 70px; background-color: white;" class="mr-3">Py Contributors</a>
66
</div>
77
</div>
88
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
9-
<span class="navbar-toggler-icon"></span>
9+
<div class="hamburger">
10+
<div class="line1"></div>
11+
<div class="line2"></div>
12+
<div class="line3"></div>
13+
</div>
1014
</button>
1115

1216
<div class="collapse navbar-collapse" id="navbarColor03">
@@ -46,4 +50,16 @@
4650
</ul>
4751
</div>
4852
</div>
49-
</nav>
53+
</nav>
54+
55+
<script>
56+
const menu = document.querySelector('.hamburger');
57+
const list = document.querySelectorAll('li');
58+
59+
menu.addEventListener('click', () => {
60+
list.forEach(item => {
61+
item.classList.toggle('active');
62+
})
63+
menu.classList.toggle('cross');
64+
})
65+
</script>

assets/css/main.css

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,77 @@ background-attachment: fixed !important;
158158
{
159159
margin-left: 50%;
160160
}
161-
}
161+
}
162+
/* Hamburger */
163+
164+
.hamburger {
165+
z-index: 1;
166+
display: inline-block;
167+
cursor: pointer;
168+
position: absolute;
169+
right: 10px;
170+
top: 10px;
171+
}
172+
173+
.line1 ,.line2 ,.line3 {
174+
width: 35px;
175+
height: 5px;
176+
background-color: white;
177+
margin: 6px 0;
178+
transition: 0.4s;
179+
}
180+
181+
.cross .line1 {
182+
transform: rotate(-45deg) translate(-9px, 6px);
183+
}
184+
185+
.cross .line2 {
186+
opacity: 0;
187+
background-color: white;
188+
}
189+
190+
.cross .line3 {
191+
transform: rotate(45deg) translate(-8px, -8px);
192+
background-color: white;
193+
}
194+
ul {
195+
height: 100%;
196+
}
197+
198+
ul li {
199+
display: flex;
200+
align-items: center;
201+
justify-content: center;
202+
height: 20%;
203+
color: white;
204+
background-color: black;
205+
text-transform: uppercase;
206+
letter-spacing: 2px;
207+
transition: all 0.4s ease-out;
208+
transform: translateX(-100%);
209+
}
210+
211+
ul li.active {
212+
transform: translateX(0);
213+
}
214+
215+
ul li:nth-child(1) {
216+
background-color: #355070;
217+
transition-delay: 0.08s;
218+
}
219+
ul li:nth-child(2) {
220+
background-color: #6D597A;
221+
transition-delay: 0.16s;
222+
}
223+
ul li:nth-child(3) {
224+
background-color: #B56576;
225+
transition-delay: 0.24s;
226+
}
227+
ul li:nth-child(4) {
228+
background-color: #E56B6F;
229+
transition-delay: 0.32s;
230+
}
231+
ul li:nth-child(5) {
232+
background-color: #EAAC8B;
233+
transition-delay: 0.40s;
234+
}

0 commit comments

Comments
 (0)