Skip to content

Commit df60d87

Browse files
committed
editing hamburger animation
1 parent ec42b24 commit df60d87

File tree

2 files changed

+46
-52
lines changed

2 files changed

+46
-52
lines changed

_includes/navbar.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
<!-- <div class="container"> -->
1616
<!-- <div class="ml-auto mr-4"> -->
1717
<div class="nav-list">
18-
<div class="hamburger"><div class="bar"></div></div>
18+
<div class="hamburger">
19+
<div class="line1"></div>
20+
<div class="line2"></div>
21+
<div class="line3"></div>
22+
</div>
1923
<ul >
2024
{% if page.active == "home" %}
2125
<li class=" active"><a class="" href="/" data-after="Home">Home</a></li>
@@ -62,13 +66,13 @@
6266
const header = document.querySelector('.header.container');
6367

6468
hamburger.addEventListener('click', () => {
65-
hamburger.classList.toggle('active');
69+
hamburger.classList.toggle('cross');
6670
mobile_menu.classList.toggle('active');
6771
});
6872

6973
menu_item.forEach((item) => {
7074
item.addEventListener('click', () => {
71-
hamburger.classList.toggle('active');
75+
hamburger.classList.toggle('cross');
7276
mobile_menu.classList.toggle('active');
7377
});
7478
});

assets/css/main.css

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ background-attachment: fixed !important;
162162

163163
/* Chnages*/
164164

165+
#header {
166+
position: fixed;
167+
z-index: 1000;
168+
left: 0;
169+
top: 0;
170+
width: 100vw;
171+
height: auto;
172+
}
173+
#header .header {
174+
min-height: 8vh;
175+
background-color: rgba(31, 30, 30, 0.24);
176+
transition: .3s ease background-color;
177+
}
178+
165179
#header .nav-bar {
166180
display: flex;
167181
align-items: center;
@@ -219,57 +233,33 @@ background-attachment: fixed !important;
219233
#header .nav-list ul li:hover a {
220234
color: crimson;
221235
}
222-
#header .hamburger {
223-
height: 60px;
224-
width: 60px;
225-
display: inline-block;
226-
border: 3px solid white;
227-
border-radius: 50%;
228-
position: relative;
229-
display: flex;
230-
align-items: center;
231-
justify-content: center;
232-
z-index: 100;
233-
cursor: pointer;
234-
transform: scale(.8);
235-
margin-right: 20px;
236-
}
237-
#header .hamburger:after {
238-
position: absolute;
239-
content: '';
240-
height: 100%;
241-
width: 100%;
242-
border-radius: 50%;
243-
border: 3px solid white;
244-
animation: hamburger_puls 1s ease infinite;
245-
}
246-
#header .hamburger .bar {
247-
height: 2px;
248-
width: 30px;
249-
position: relative;
250-
background-color: white;
251-
z-index: -1;
252-
}
253-
#header .hamburger .bar::after,
254-
#header .hamburger .bar::before {
255-
content: '';
256-
position: absolute;
257-
height: 100%;
258-
width: 100%;
259-
left: 0;
260-
background-color: white;
261-
transition: .3s ease;
262-
transition-property: top, bottom;
236+
.hamburger {
237+
z-index: 1;
238+
display: inline-block;
239+
cursor: pointer;
240+
position: absolute;
241+
right: 10px;
242+
top: 10px;
263243
}
264-
#header .hamburger .bar::after {
265-
top: 8px;
244+
245+
.line1 ,.line2 ,.line3 {
246+
width: 35px;
247+
height: 5px;
248+
background-color: white;
249+
margin: 6px 0;
250+
transition: 0.4s;
266251
}
267-
#header .hamburger .bar::before {
268-
bottom: 8px;
252+
253+
.cross .line1 {
254+
transform: rotate(-45deg) translate(-9px, 6px);
269255
}
270-
#header .hamburger.active .bar::before {
271-
bottom: 0;
256+
257+
.cross .line2 {
258+
opacity: 0;
259+
background-color: white;
272260
}
273-
#header .hamburger.active .bar::after {
274-
top: 0;
261+
262+
.cross .line3 {
263+
transform: rotate(45deg) translate(-8px, -8px);
264+
background-color: white;
275265
}

0 commit comments

Comments
 (0)