Create a responsive navbar that hides on scroll down and reappears when scrolling up…
- User
Create a responsive navbar that hides on scroll down and reappears when scrolling up using HTML, JS, and CSS.
Assistant
The user wants a responsive navbar that:
- Hides when scrolling down
- Reappears when scrolling up
- Should be visually striking, not template-y
- Modern, polished design with meaningful interactions
Let me create something with:
- A distinctive design aesthetic (not the typical boring navbar)
- Smooth hide/show animations
- Mobile responsive with a hamburger menu
- Good visual hierarchy
- Proper CSS variables for theming
- At least one signature interaction element
Design direction:
- I'll go with a modern, slightly brutalist/technical aesthetic
- Dark theme with a sharp accent color (maybe cyan/teal or a coral)
- Bold typography
- Glassmorphism effect for the navbar
- Smooth transform transitions for hide/show
- Mobile hamburger menu with smooth animation
Let me implement this: I'll create a striking navbar with hide-on-scroll behavior, featuring a technical/modern aesthetic with smooth animations and a mobile-responsive design.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Smart Navbar</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"> <style> :root { --bg: #0a0a0f; --bg-elevated: #12121a; --fg: #f0f0f5; --muted: #6b6b7a; --accent: #00d4aa; --accent-dim: rgba(0, 212, 170, 0.15); --border: rgba(255, 255, 255, 0.08); --glow: rgba(0, 212, 170, 0.4); } * { margin: 0; padding: 0; box-sizing: border-box; } html { scroll-behavior: smooth; } body { font-family: 'Space Grotesk', sans-serif; background: var(--bg); color: var(--fg); min-height: 300vh; overflow-x: hidden; } /* Background pattern */ body::before { content: ''; position: fixed; inset: 0; background: radial-gradient(circle at 20% 20%, rgba(0, 212, 170, 0.03) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(100, 100, 255, 0.03) 0%, transparent 50%); pointer-events: none; z-index: -1; } /* Navbar base */ .navbar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: 1rem 2rem; transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, background 0.3s ease, box-shadow 0.3s ease; } .navbar.hidden { transform: translateY(-100%); opacity: 0; } .navbar.scrolled { padding: 0.75rem 2rem; } .navbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; background: rgba(18, 18, 26, 0.8); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 16px; padding: 0.75rem 1.5rem; transition: all 0.3s ease; } .navbar.scrolled .navbar-inner { background: rgba(18, 18, 26, 0.95); border-color: rgba(0, 212, 170, 0.1); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 212, 170, 0.05); } /* Logo */ .logo { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.25rem; color: var(--fg); text-decoration: none; transition: color 0.2s ease; } .logo:hover { color: var(--accent); } .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent), #00a080); border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease, box-shadow 0.3s ease; } .logo:hover .logo-icon { transform: rotate(-5deg) scale(1.05); box-shadow: 0 4px 20px var(--glow); } .logo-icon svg { width: 20px; height: 20px; color: var(--bg); } /* Nav links */ .nav-links { display: flex; align-items: center; gap: 0.5rem; list-style: none; } .nav-link { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; font-weight: 500; color: var(--muted); text-decoration: none; padding: 0.5rem 1rem; border-radius: 8px; position: relative; transition: all 0.25s ease; } .nav-link::before { content: ''; position: absolute; inset: 0; border-radius: 8px; background: var(--accent-dim); opacity: 0; transition: opacity 0.25s ease; } .nav-link:hover { color: var(--accent); } .nav-link:hover::before { opacity: 1; } .nav-link span { position: relative; z-index: 1; } /* Indicator dot */ .nav-link.active::after { content: ''; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; background: var(--accent); border-radius: 50%; } /* CTA Button */ .cta-btn { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; font-weight: 500; background: var(--accent); color: var(--bg); border: none; padding: 0.6rem 1.25rem; border-radius: 8px; cursor: pointer; position: relative; overflow: hidden; transition: all 0.3s ease; } .cta-btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, transparent, rgba(255,255,255,0.2), transparent); transform: translateX(-100%); transition: transform 0.5s ease; } .cta-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 20px var(--glow); } .cta-btn:hover::before { transform: translateX(100%); } .cta-btn:active { transform: translateY(0); } /* Mobile menu button */ .menu-btn { display: none; width: 44px; height: 44px; background: transparent; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; position: relative; flex-direction: column; align-items: center; justify-content: center; gap: 5px; transition: all 0.3s ease; } .menu-btn:hover { border-color: var(--accent); background: var(--accent-dim); } .menu-btn span { display: block; width: 18px; height: 2px; background: var(--fg); border-radius: 2px; transition: all 0.3s ease; } .menu-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); } .menu-btn.active span:nth-child(2) { opacity: 0; } .menu-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); } /* Mobile menu */ .mobile-menu { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(10, 10, 15, 0.98); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); z-index: 999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; opacity: 0; pointer-events: none; transition: opacity 0.4s ease; } .mobile-menu.active { opacity: 1; pointer-events: auto; } .mobile-menu .nav-link { font-size: 1.5rem; padding: 1rem 2rem; } .mobile-menu .cta-btn { margin-top: 1rem; padding: 1rem 2.5rem; font-size: 1rem; } /* Content sections */ .section { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8rem 2rem 4rem; text-align: center; } .section h1 { font-size: clamp(2.5rem, 8vw, 5rem); font-weight: 700; line-height: 1.1; margin-bottom: 1.5rem; background: linear-gradient(135deg, var(--fg), var(--muted)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } .section h1 .accent { background: linear-gradient(135deg, var(--accent), #00ffcc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } .section p { font-size: 1.125rem; color: var(--muted); max-width: 600px; line-height: 1.7; } .scroll-indicator { position: absolute; bottom: 3rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.75rem; font-family: 'JetBrains Mono', monospace; animation: bounce 2s infinite; } @keyframes bounce { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(10px); } } .scroll-indicator svg { width: 20px; height: 20px; } /* Responsive */ @media (max-width: 768px) { .navbar { padding: 0.75rem 1rem; } .nav-links { display: none; } .cta-btn { display: none; } .menu-btn { display: flex; } .logo { font-size: 1.1rem; } .logo-icon { width: 32px; height: 32px; } } /* Focus states */ .nav-link:focus-visible, .cta-btn:focus-visible, .logo:focus-visible, .menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } /* Reduced motion */ @media (prefers-reduced-motion: reduce) { .navbar, .nav-link, .cta-btn, .menu-btn span, .scroll-indicator { transition: none; animation: none; } } </style> </head> <body> <!-- Navbar --> <nav class="navbar" role="navigation" aria-label="Main navigation"> <div class="navbar-inner"> <a href="#" class="logo" aria-label="Vertex Home"> <div class="logo-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"> <polygon points="12 2 2 7 12 12 22 7 12 2"></polygon> <polyline points="2 17 12 22 22 17"></polyline> <polyline points="2 12 12 17 22 12"></polyline> </svg> </div> <span>Vertex</span> </a> <ul class="nav-links"> <li><a href="#" class="nav-link active" aria-current="page"><span>Home</span></a></li> <li><a href="#" class="nav-link"><span>Products</span></a></li> <li><a href="#" class="nav-link"><span>Solutions</span></a></li> <li><a href="#" class="nav-link"><span>Developers</span></a></li> <li><a href="#" class="nav-link"><span>Pricing</span></a></li> </ul> <button class="cta-btn">Get Started</button> <button class="menu-btn" aria-label="Toggle menu" aria-expanded="false"> <span></span> <span></span> <span></span> </button> </div> </nav> <!-- Mobile Menu --> <div class="mobile-menu" aria-hidden="true"> <a href="#" class="nav-link active"><span>Home</span></a> <a href="#" class="nav-link"><span>Products</span></a> <a href="#" class="nav-link"><span>Solutions</span></a> <a href="#" class="nav-link"><span>Developers</span></a> <a href="#" class="nav-link"><span>Pricing</span></a> <button class="cta-btn">Get Started</button> </div> <!-- Content Sections --> <section class="section"> <h1>Build the <span class="accent">future</span><br>with precision</h1> <p>A next-generation platform for developers who demand performance, elegance, and reliability in every line of code.</p> <div class="scroll-indicator"> <span>Scroll to explore</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 5v14M19 12l-7 7-7-7"/> </svg> </div> </section> <section class="section" style="background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%);"> <h1>Designed for <span class="accent">scale</span></h1> <p>From prototype to production, our infrastructure grows with you seamlessly. No compromises, no limits.</p> </section> <section class="section"> <h1>Security <span class="accent">first</span></h1> <p>Enterprise-grade protection built into every layer. Your data, your rules, your peace of mind.</p> </section> <script> // Initialize variables first let lastScrollY = window.scrollY; let ticking = false; let mobileMenuOpen = false; // Get DOM elements const navbar = document.querySelector('.navbar'); const menuBtn = document.querySelector('.menu-btn'); const mobileMenu = document.querySelector('.mobile-menu'); // Scroll handler with proper direction detection function updateNavbar() { const currentScrollY = window.scrollY; const scrollDelta = currentScrollY - lastScrollY; // Add scrolled class when not at top if (currentScrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } // Hide on scroll down, show on scroll up // Only trigger if scrolled more than threshold if (Math.abs(scrollDelta) > 5) { if (scrollDelta > 0 && currentScrollY > 100) { // Scrolling down & past threshold navbar.classList.add('hidden'); } else { // Scrolling up navbar.classList.remove('hidden'); } } lastScrollY = currentScrollY; ticking = false; } // Throttled scroll listener window.addEventListener('scroll', function() { if (!ticking) { window.requestAnimationFrame(updateNavbar); ticking = true; } }, { passive: true }); // Mobile menu toggle function toggleMobileMenu() { mobileMenuOpen = !mobileMenuOpen; menuBtn.classList.toggle('active', mobileMenuOpen); mobileMenu.classList.toggle('active', mobileMenuOpen); // Update ARIA attributes menuBtn.setAttribute('aria-expanded', mobileMenuOpen); mobileMenu.setAttribute('aria-hidden', !mobileMenuOpen); // Prevent body scroll when menu is open document.body.style.overflow = mobileMenuOpen ? 'hidden' : ''; } menuBtn.addEventListener('click', toggleMobileMenu); // Close mobile menu on link click const mobileLinks = mobileMenu.querySelectorAll('.nav-link'); mobileLinks.forEach(function(link) { link.addEventListener('click', function() { if (mobileMenuOpen) { toggleMobileMenu(); } }); }); // Close mobile menu on escape key document.addEventListener('keydown', function(e) { if (e.key === 'Escape' && mobileMenuOpen) { toggleMobileMenu(); } }); // Close mobile menu on resize to desktop let resizeTimer = null; window.addEventListener('resize', function() { if (resizeTimer !== null) { clearTimeout(resizeTimer); } resizeTimer = setTimeout(function() { if (window.innerWidth > 768 && mobileMenuOpen) { toggleMobileMenu(); } }, 100); }); // Initial state check updateNavbar(); </script> </body> </html>Key Features
Hide/Show Behavior:
- Uses
requestAnimationFramefor smooth, throttled scroll detection - Hides navbar when scrolling down past 100px threshold
- Immediately reveals navbar when scrolling up
- Smooth CSS transitions with cubic-bezier easing
Visual Design:
- Dark technical aesthetic with teal accent color
- Glassmorphism effect with backdrop blur
- Subtle gradient background with depth
- JetBrains Mono for nav links (technical feel), Space Grotesk for headings
Interactions:
- Logo hover with rotation and glow effect
- Nav links with background reveal on hover
- CTA button with shine sweep animation
- Mobile hamburger transforms to X
Responsive:
- Full-screen mobile menu with blur backdrop
- Touch-friendly tap targets (44px minimum)
- Graceful resize handling
Accessibility:
- Semantic HTML with ARIA labels
- Focus-visible states for keyboard navigation
prefers-reduced-motionsupport- Escape key closes mobile menu
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.