Skip to content

Commit

Permalink
Added responsive nav-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
kevalpithadiya committed Feb 24, 2024
1 parent 3ad75ff commit b453e53
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 11 deletions.
71 changes: 64 additions & 7 deletions css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ body {
margin: 0;
}

.no-display {
display: none !important;
}

/* Header */
.header-container {
position: absolute;
Expand All @@ -23,7 +27,7 @@ body {
align-items: center;
justify-content: space-between;
width: 100%;
height: 12vh;
height: 94px;
background-color: #fff;
border-bottom: 3px solid rgb(61, 77, 173);
}
Expand Down Expand Up @@ -57,6 +61,65 @@ body {
color: rgb(61, 77, 173);
}

.header-mob-nav-btn {
display: none;
width: 35px;
height: calc(60px - 12.5px);
padding-top: 10px;
cursor: pointer;
margin-right: 20px;
}

.header-mob-nav-btn span {
display: block;
width: 100%;
height: 5px;
background-color: black;
margin: 5px 0;
}

.header-mob-nav {
position: fixed;
top: 94px;
left: 0;
height: 100vh;
width: 100vw;
padding: 50px;
box-sizing: border-box;

background-color: #000000b0;
font-size: 32px;
color: white;
font-family: Arial, Helvetica, sans-serif;
text-align: center;

display: flex;
flex-direction: column;
}

.header-mob-nav a {
margin: 15px 0;
text-shadow: 5px 5px 10px black;
}

.header-mob-nav a.active {
color: rgb(61, 77, 173);
}

@media screen and (max-width: 850px) {
.header-nav {
display: none;
}

.header-container {
position: fixed;
}

.header-mob-nav-btn {
display: inline-block;
}
}

.main {
margin-top: 94px;
}
Expand Down Expand Up @@ -98,12 +161,6 @@ body {
color: rgb(61, 77, 173);
}

@media screen and (max-width: 800px) {
.header-nav {
display: none;
}
}

@keyframes fadeIn {
from {
opacity: 0;
Expand Down
1 change: 1 addition & 0 deletions scripts/activepage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
console.log(window.location.pathname);
document.addEventListener("DOMContentLoaded", () => {
document.querySelector(`a.header-nav-item[href="${window.location.pathname}"`).classList.add("active");
document.querySelector(`header-mob-nav a[href="${window.location.pathname}"`).classList.add("active");
});
25 changes: 21 additions & 4 deletions scripts/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ const headerContent= `
<a class="header-nav-item" href="${origin}/activities/">Activities</a>
<a class="header-nav-item" href="${origin}/contact/">Contact</a>
</div>
</div>
`;
<div class="header-mob-nav-btn">
<span></span>
<span></span>
<span></span>
<p style="display: none">x</p>
</div>
<div class="header-mob-nav no-display">
<a class="header-mob-nav-item" href="${origin}/">Home</a>
<a class="header-mob-nav-item" href="${origin}/gallery/">Gallery</a>
<a class="header-mob-nav-item" href="${origin}/the-team/">The Team</a>
<a class="header-mob-nav-item" href="${origin}/activities/">Activities</a>
<a class="header-mob-nav-item" href="${origin}/contact/">Contact</a>
</div>
</div>
`;

const footerContent = `
<div class="Main_text"><b>Join our mailing list for updates on events and for receiving our newsletter!</b></div>
Expand All @@ -30,6 +43,10 @@ const footerContent = `
// });

headerComponents.forEach(element=>{

element.innerHTML=headerContent;
})
});

// Attach toggle function for header-mob-nav
document.querySelector(".header-mob-nav-btn").addEventListener("click", () => {
document.querySelector(".header-mob-nav").classList.toggle("no-display");
});

0 comments on commit b453e53

Please sign in to comment.