A lightweight, responsive navigation menu built with HTML, CSS, and Vanilla JavaScript. It features a smooth hamburger animation and handles body scroll locking to prevent layout shifts.
π View Live Demo on GitHub Pages
This project demonstrates a classic mobile navigation pattern. On desktop screens, it displays a standard horizontal menu. On mobile screens (under 767px), it switches to a "Burger" icon that toggles a full-screen navigation overlay.
- Responsive Design: Automatically adapts layout based on screen width using CSS Media Queries.
- Animated Icon: The burger icon smoothly transforms into a cross ("X") using CSS transitions.
- Scroll Locking: When the menu is open, the background scrolling is disabled (
overflow: hidden). - Layout Shift Prevention: The JavaScript dynamically calculates the browser's scrollbar width and adds equivalent padding to the body when locking the scroll. This prevents the page content from "jumping" to the right when the scrollbar disappears.
- HTML5
- CSS3 (Flexbox, Positioning, Transitions)
- JavaScript (ES6+)
- DOM Manipulation
- Event Listeners
- Dynamic style calculation
- Clone the repository:
git clone [https://github.com/YOUR_USERNAME/REPO_NAME.git](https://github.com/YOUR_USERNAME/REPO_NAME.git)
- Open
index.htmlin your browser.
index.htmlβ Main layout structure.style.cssβ Styles for the header, navigation, and animations.main.jsβ Logic for the burger menu toggle and scrollbar width calculation.
Created for educational purposes.