Skip to content

Commit

Permalink
ddd
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy0318 committed Dec 15, 2024
1 parent 3588dbc commit a9039f6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
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

0 comments on commit a9039f6

Please sign in to comment.