Skip to content

Commit 72b87d6

Browse files
committed
create events to open and close the nav-columnar-menu
1 parent 4a74e24 commit 72b87d6

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

css/navbar.css

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
color: var(--default-font-color);
2727
text-decoration: none;
2828
transition: all 0.5s ease-in-out;
29-
29+
3030
}
3131

3232
.nav-link:hover {
@@ -48,20 +48,37 @@
4848
display: none;
4949
position: fixed;
5050
top: 0;
51-
width:100%;
52-
z-index: 9999;
51+
width: 100%;
52+
z-index: 2;
5353
background-color: rgb(38, 26, 50);
5454

5555
}
5656

5757
.nav-header-menu {
58+
position: absolute;
5859
padding: 0.5em;
60+
z-index: 3;
61+
width: 100%;
62+
background-color: rgb(38, 26, 50);
5963
}
6064

61-
.nav-menu {
65+
#nav-columnar-menu {
66+
position: absolute;
6267
margin-top: 0;
6368
padding-left: 0;
64-
height: 70vh;
69+
height: 50vh;
70+
background-color: rgb(38, 26, 50);
71+
width: 100%;
72+
z-index: 2;
73+
top: -50vh;
74+
transition: all 0.3s ease-in;
75+
76+
}
77+
78+
#nav-columnar-menu.active {
79+
top: 1em;
80+
transition: all 0.8s ease-in;
81+
6582
}
6683

6784
.nav-element {

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
</nav>
5454
<nav class="navbar-compressed">
5555
<div class="nav-header-menu">
56-
<a href="#" class="icon-link"><i class="fa fa-bars fa-lg"></i></a>
56+
<a class="icon-link" id="show-nav-columnar-menu"><i class="fa fa-bars fa-lg"></i></a>
5757
</div>
58-
<ul class="nav-menu">
58+
<ul id="nav-columnar-menu">
5959
<li class="nav-element">
6060
<a class="nav-link compressed" href="#"><h2>Home</h2></a>
6161
</li>

index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,31 @@ function reveal() {
1313
}
1414
})
1515
}
16-
window.addEventListener("scroll", reveal)
16+
window.addEventListener("scroll", reveal)
17+
document.addEventListener("DOMContentLoaded", function (event) {
18+
[...document.getElementsByTagName("a")].forEach(
19+
function (element) {
20+
element.addEventListener('click', function () {
21+
const navColumnarMenu = document.getElementById('nav-columnar-menu');
22+
if (navColumnarMenu.classList.contains('active')) {
23+
navColumnarMenu.classList.remove("active");
24+
}
25+
else if(element.id==='show-nav-columnar-menu'){
26+
navColumnarMenu.classList.add("active");
27+
}
28+
29+
})
30+
}
31+
)
32+
// Your code to run since DOM is loaded and ready
33+
})
34+
// ([...document.getElementsByTagName('a')]).forEach(
35+
// // (a)=>{
36+
37+
// // }
38+
// // (element=>{
39+
// // element.addEventListener('click',function(){
40+
// // console.log('aaaaaaaaa')
41+
// // })
42+
// // })
43+
// )

0 commit comments

Comments
 (0)