Responsive Navbar HTML CSS — 30 Patterns with Code
Every navigation pattern you need for real projects — basic horizontal nav, hamburger menus, dropdowns, glassmorphism, sticky, bottom tabs and more. Live preview + copy-ready HTML & CSS.
30
Nav Patterns
6
Categories
HTML+CSS
Copy-ready
A11y
Accessible
Frequently Asked Questions
How do I make a responsive navbar in HTML and CSS?
Build a <nav> with a logo and a <ul> of links. On desktop use Flexbox: display:flex; justify-content:space-between; align-items:center. Below 768px, hide the link list (display:none) and show a hamburger button. Toggle a class with JavaScript to reveal the menu on click.
How do I make a sticky navbar in CSS?
Apply position: sticky; top: 0; z-index: 100; to your <nav>. Unlike fixed, sticky keeps the element in document flow until it hits the scroll boundary. Add background and box-shadow so the navbar is visible over scrolled content.
How do I create a CSS-only hamburger menu?
Use a hidden <input type="checkbox"> and a <label> styled as three horizontal lines. When checked, use input:checked ~ .nav-menu { display: flex; } to reveal the menu. No JavaScript needed, though JS is recommended for screen reader aria-expanded states.
How do I add a dropdown to a CSS navbar?
Wrap the nav item and dropdown in a position:relative container. Set the dropdown to position:absolute; top:100%; visibility:hidden; opacity:0. On parent :hover and :focus-within, set visibility:visible; opacity:1. Use transition:opacity .2s for smooth animation.
What z-index should a navbar use?
Use z-index: 100 for a standard sticky navbar — enough to sit above page content. If you have modals (typically z-index 200–400) or tooltips, keep the nav below those values. Remember: z-index only works when position is set to sticky, fixed, relative, or absolute.
`,
code:`
`},
{id:30,cat:'advanced',name:'Progress-Aware Sticky Nav',desc:'Reading progress bar under the navbar — articles and long-form pages.',
preview:`
Progress bar at 65% — fills as user scrolls the article
`,
code:`
`},
];
// ─── RENDER ───────────────────────────────────────────────────────────────────
const BADGE={basic:'Basic',mobile:'Mobile',style:'Style',dropdown:'Dropdown',special:'Special',advanced:'Advanced'};
function escHtml(s){return s.replace(/&/g,'&').replace(//g,'>');}
function buildCard(n){
return `