Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the hamburger icon for home page #1915

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5502
}
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
<span class="bar"></span>
<span class="bar"></span>
</div>
<ul class="nav-menu">
<!-- Additional nav items -->
</ul>

</nav>
</header>
<!-- Navigation bar section ends -->
Expand Down
37 changes: 25 additions & 12 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,34 @@ document.addEventListener("DOMContentLoaded", function () {
}, 500);
});

// Hamburger menu
hamburger.addEventListener("click", mobileMenu);
document.addEventListener("DOMContentLoaded", () => {
const hamburger = document.querySelector(".hamburger");
const navMenu = document.querySelector(".nav-menu");

// Verify the elements exist
if (!hamburger || !navMenu) {
console.error("Hamburger or nav-menu element not found.");
return;
}

function mobileMenu() {
hamburger.classList.toggle("active");
navMenu.classList.toggle("active");
}
// Attach click event to toggle menu visibility
hamburger.addEventListener("click", () => {
console.log("Hamburger clicked.");
hamburger.classList.toggle("active");
navMenu.classList.toggle("show");
});

const navLink = document.querySelectorAll(".nav-link");
navLink.forEach(n => n.addEventListener("click", closeMenu));
// Close menu when a link is clicked
const navLinks = document.querySelectorAll(".nav-link");
navLinks.forEach(link => {
link.addEventListener("click", () => {
console.log("Nav link clicked.");
hamburger.classList.remove("active");
navMenu.classList.remove("show");
});
});
});

function closeMenu() {
hamburger.classList.remove("active");
navMenu.classList.remove("active");
}

// Google Translate
function googleTranslateElementInit() {
Expand Down
9 changes: 7 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2174,10 +2174,15 @@ footer {
backdrop-filter: blur(7px);
transition: 0.5s ease-in-out;
}
.nav-menu.show {
display: flex; /* Or block, depending on your design */
}


.nav-item {
margin: 3.5rem 0;
font-size: 20px;
margin: 10px ;
font-size: 30px;

}

nav li:hover {
Expand Down
Loading