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

Navbar background scrolling on home page #841 #852

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions Css-files/navbarstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ body {
color: #d2691e;
}

/* Add these styles for mobile menu */
body.menu-open {
overflow: hidden;
position: fixed;
width: 100%;
}

/* Mobile Styles */
@media (max-width: 768px) {
.navbar-brand {
Expand All @@ -164,4 +171,26 @@ body {
.nav-item {
margin-bottom: 1rem;
}

.navbar-collapse {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 245, 0.95);
padding: 80px 20px 20px;
overflow-y: auto;
transform: translateX(-100%);
transition: transform 0.3s ease-in-out;
z-index: 1029;
}

.navbar-collapse.show {
transform: translateX(0);
}

.navbar-nav {
height: 100%;
}
}
31 changes: 31 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,38 @@

document.body.classList.add('light-mode');

document.addEventListener('DOMContentLoaded', function() {
const hamburger = document.querySelector('.navbar-toggler');
const navLinks = document.querySelectorAll('.nav-link');
const body = document.body;
const navbarCollapse = document.querySelector('.navbar-collapse');

// Existing hamburger click handler
hamburger.addEventListener('click', function() {
if (this.getAttribute('aria-expanded') === 'true') {
body.classList.add('menu-open');
} else {
body.classList.remove('menu-open');
}
});

// Add click handler for nav links
navLinks.forEach(link => {
link.addEventListener('click', function() {
if (navbarCollapse.classList.contains('show')) {
hamburger.click(); // Simulate click on hamburger to close menu
}
});
});

// Close menu when clicking outside
document.addEventListener('click', function(e) {
const navbar = document.querySelector('.navbar');
if (!navbar.contains(e.target) && navbarCollapse.classList.contains('show')) {
hamburger.click();
}
});
});
</script>
<!--Navbar End-->

Expand Down
Loading