<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Navigation</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@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0a0b;
--bg-elevated: #141416;
--fg: #fafafa;
--muted: #71717a;
--accent: #22d3ee;
--accent-dim: rgba(34, 211, 238, 0.15);
--border: rgba(255, 255, 255, 0.08);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
font-family: 'Inter', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 200vh;
overflow-x: hidden;
}
/* Navigation Base */
.nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
padding: 1rem 1.5rem;
transition: background 0.3s ease, backdrop-filter 0.3s ease;
}
.nav.scrolled {
background: rgba(10, 10, 11, 0.85);
backdrop-filter: blur(20px);
border-bottom: 1px solid var(--border);
}
.nav-container {
max-width: 1400px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
}
/* Logo */
.logo {
font-family: 'Space Grotesk', sans-serif;
font-size: 1.5rem;
font-weight: 700;
letter-spacing: -0.03em;
color: var(--fg);
text-decoration: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.logo-icon {
width: 32px;
height: 32px;
background: linear-gradient(135deg, var(--accent) 0%, #06b6d4 100%);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo:hover .logo-icon {
transform: rotate(-10deg) scale(1.05);
}
/* Desktop Navigation */
.nav-links {
display: none;
align-items: center;
gap: 0.5rem;
}
@media (min-width: 768px) {
.nav-links {
display: flex;
}
}
.nav-link {
font-family: 'Space Grotesk', sans-serif;
font-size: 0.9rem;
font-weight: 500;
color: var(--muted);
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 8px;
position: relative;
transition: color 0.2s ease;
}
.nav-link::before {
content: '';
position: absolute;
inset: 0;
border-radius: 8px;
background: var(--accent-dim);
opacity: 0;
transition: opacity 0.2s ease;
}
.nav-link:hover {
color: var(--fg);
}
.nav-link:hover::before {
opacity: 1;
}
.nav-link span {
position: relative;
z-index: 1;
}
/* Active link indicator */
.nav-link.active {
color: var(--accent);
}
.nav-link.active::after {
content: '';
position: absolute;
bottom: 4px;
left: 50%;
transform: translateX(-50%);
width: 4px;
height: 4px;
background: var(--accent);
border-radius: 50%;
}
/* CTA Button */
.nav-cta {
display: none;
font-family: 'Space Grotesk', sans-serif;
font-size: 0.875rem;
font-weight: 600;
color: var(--bg);
background: var(--fg);
padding: 0.625rem 1.25rem;
border-radius: 8px;
text-decoration: none;
transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
@media (min-width: 768px) {
.nav-cta {
display: block;
}
}
.nav-cta:hover {
transform: translateY(-2px);
box-shadow: 0 8px 24px rgba(255, 255, 255, 0.15);
}
.nav-cta:active {
transform: translateY(0);
}
/* Hamburger Button */
.hamburger {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 44px;
height: 44px;
background: transparent;
border: 1px solid var(--border);
border-radius: 10px;
cursor: pointer;
transition: background 0.2s ease, border-color 0.2s ease;
}
@media (min-width: 768px) {
.hamburger {
display: none;
}
}
.hamburger:hover {
background: var(--bg-elevated);
border-color: rgba(255, 255, 255, 0.15);
}
.hamburger:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.hamburger-line {
width: 20px;
height: 2px;
background: var(--fg);
border-radius: 2px;
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}
.hamburger-line:nth-child(1) {
transform: translateY(-5px);
}
.hamburger-line:nth-child(3) {
transform: translateY(5px);
}
/* Hamburger Active State */
.hamburger.active .hamburger-line:nth-child(1) {
transform: translateY(0) rotate(45deg);
}
.hamburger.active .hamburger-line:nth-child(2) {
opacity: 0;
transform: scaleX(0);
}
.hamburger.active .hamburger-line:nth-child(3) {
transform: translateY(-2px) rotate(-45deg);
}
/* Mobile Menu Overlay */
.mobile-menu {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--bg);
z-index: 90;
display: flex;
flex-direction: column;
justify-content: center;
padding: 2rem;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.mobile-menu.active {
opacity: 1;
visibility: visible;
}
/* Background Pattern */
.mobile-menu-bg {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.mobile-menu-bg::before {
content: '';
position: absolute;
top: -50%;
right: -20%;
width: 80%;
height: 80%;
background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
opacity: 0.5;
}
.mobile-menu-bg::after {
content: '';
position: absolute;
bottom: -30%;
left: -10%;
width: 60%;
height: 60%;
background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
}
/* Mobile Menu Links */
.mobile-nav-links {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.mobile-nav-link {
font-family: 'Space Grotesk', sans-serif;
font-size: clamp(2rem, 8vw, 3.5rem);
font-weight: 700;
letter-spacing: -0.03em;
color: var(--muted);
text-decoration: none;
padding: 0.5rem 0;
transform: translateY(30px);
opacity: 0;
transition: color 0.2s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}
.mobile-menu.active .mobile-nav-link {
transform: translateY(0);
opacity: 1;
}
.mobile-nav-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-nav-link:nth-child(2) { transition-delay: 0.15s; }
.mobile-nav-link:nth-child(3) { transition-delay: 0.2s; }
.mobile-nav-link:nth-child(4) { transition-delay: 0.25s; }
.mobile-nav-link:nth-child(5) { transition-delay: 0.3s; }
.mobile-nav-link:hover {
color: var(--fg);
}
.mobile-nav-link span {
display: inline-block;
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mobile-nav-link:hover span {
transform: translateX(12px);
}
.mobile-nav-link.active {
color: var(--accent);
}
/* Mobile CTA */
.mobile-cta {
font-family: 'Space Grotesk', sans-serif;
font-size: 1rem;
font-weight: 600;
color: var(--bg);
background: var(--fg);
padding: 1rem 2rem;
border-radius: 12px;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.5rem;
margin-top: 2rem;
width: fit-content;
transform: translateY(20px);
opacity: 0;
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s, opacity 0.4s ease 0.35s, background 0.2s ease;
}
.mobile-menu.active .mobile-cta {
transform: translateY(0);
opacity: 1;
}
.mobile-cta:hover {
background: var(--accent);
}
.mobile-cta svg {
transition: transform 0.2s ease;
}
.mobile-cta:hover svg {
transform: translateX(4px);
}
/* Demo Content */
.hero {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 6rem 2rem 2rem;
position: relative;
}
.hero-bg {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.hero-bg::before {
content: '';
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: 100%;
max-width: 800px;
height: 100%;
background: radial-gradient(ellipse, var(--accent-dim) 0%, transparent 70%);
}
.hero h1 {
font-family: 'Space Grotesk', sans-serif;
font-size: clamp(2.5rem, 10vw, 5rem);
font-weight: 700;
letter-spacing: -0.04em;
line-height: 1.1;
margin-bottom: 1.5rem;
position: relative;
}
.hero p {
font-size: 1.125rem;
color: var(--muted);
max-width: 500px;
line-height: 1.6;
}
.scroll-indicator {
position: absolute;
bottom: 2rem;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
color: var(--muted);
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.1em;
animation: bounce 2s infinite;
}
@keyframes bounce {
0%, 100% { transform: translateX(-50%) translateY(0); }
50% { transform: translateX(-50%) translateY(8px); }
}
/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<!-- Navigation -->
<nav class="nav" role="navigation" aria-label="Main navigation">
<div class="nav-container">
<a href="#" class="logo" aria-label="Stellar home">
<div class="logo-icon">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
</svg>
</div>
Stellar
</a>
<!-- Desktop Links -->
<div class="nav-links">
<a href="#" class="nav-link active"><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>
<a href="#" class="nav-link"><span>Company</span></a>
</div>
<a href="#" class="nav-cta">Get Started</a>
<!-- Hamburger -->
<button class="hamburger" aria-label="Toggle menu" aria-expanded="false">
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
</button>
</div>
</nav>
<!-- Mobile Menu -->
<div class="mobile-menu" aria-hidden="true">
<div class="mobile-menu-bg"></div>
<div class="mobile-nav-links">
<a href="#" class="mobile-nav-link active"><span>Products</span></a>
<a href="#" class="mobile-nav-link"><span>Solutions</span></a>
<a href="#" class="mobile-nav-link"><span>Developers</span></a>
<a href="#" class="mobile-nav-link"><span>Pricing</span></a>
<a href="#" class="mobile-nav-link"><span>Company</span></a>
</div>
<a href="#" class="mobile-cta">
Get Started
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="5" y1="12" x2="19" y2="12"></line>
<polyline points="12 5 19 12 12 19"></polyline>
</svg>
</a>
</div>
<!-- Demo Content -->
<main>
<section class="hero">
<div class="hero-bg"></div>
<h1>Navigate the Future</h1>
<p>Experience seamless navigation with elegant transitions and thoughtful interactions at every breakpoint.</p>
<div class="scroll-indicator">
<span>Scroll</span>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19"></line>
<polyline points="19 12 12 19 5 12"></polyline>
</svg>
</div>
</section>
</main>
<script>
// Elements
const nav = document.querySelector('.nav');
const hamburger = document.querySelector('.hamburger');
const mobileMenu = document.querySelector('.mobile-menu');
const mobileLinks = document.querySelectorAll('.mobile-nav-link');
// Scroll handling for nav background
let lastScroll = 0;
function handleScroll() {
const currentScroll = window.pageYOffset;
if (currentScroll > 50) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
lastScroll = currentScroll;
}
window.addEventListener('scroll', handleScroll, { passive: true });
// Hamburger toggle
function toggleMenu() {
const isActive = hamburger.classList.contains('active');
hamburger.classList.toggle('active');
mobileMenu.classList.toggle('active');
// Accessibility
hamburger.setAttribute('aria-expanded', !isActive);
mobileMenu.setAttribute('aria-hidden', isActive);
// Prevent body scroll when menu is open
document.body.style.overflow = isActive ? '' : 'hidden';
}
hamburger.addEventListener('click', toggleMenu);
// Close menu on link click
mobileLinks.forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
mobileMenu.classList.remove('active');
hamburger.setAttribute('aria-expanded', 'false');
mobileMenu.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
});
});
// Close menu on escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && mobileMenu.classList.contains('active')) {
toggleMenu();
}
});
// Close menu on window resize above mobile breakpoint
let resizeTimer;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
if (window.innerWidth >= 768 && mobileMenu.classList.contains('active')) {
hamburger.classList.remove('active');
mobileMenu.classList.remove('active');
hamburger.setAttribute('aria-expanded', 'false');
mobileMenu.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
}
}, 100);
});
// Initial check
handleScroll();
</script>
</body>
</html>