What is Stellix Nav?
The header is the first thing a visitor sees and the part they use most. A good header must look clean on a big monitor and still be easy to tap on a small phone. Stellix Nav is a modern header built for exactly that. It is one HTML file, with plain CSS and a small amount of JavaScript, so you can drop it into any project.
The desktop view
On a wide screen the header floats at the top as a rounded glass bar with a soft blur behind it. It holds the logo, five links, a dark mode button and a gradient call-to-action button. A soft highlight pill slides smoothly to whichever link you hover, then settles on the section you are currently reading. Hover the Services link and a dropdown card opens with three options, each with an icon and a short description.
The mobile view
On a phone, the links and the button tuck away, and a single menu button remains. The three lines turn into an X when you tap it, and a rounded menu slides down with large, easy-to-tap links. Services expands like an accordion. The menu closes when you tap a link, tap outside, press Escape, or rotate the phone into a wide layout.
Features
- Floating glass header with blur and a soft shadow
- Sliding highlight pill that follows the hovered link
- Active link detection while you scroll
- Dropdown menu that opens on hover and on keyboard focus
- Animated hamburger that morphs into a close icon
- Mobile menu with an accordion for sub-links
- Light and dark mode with a toggle that remembers your choice
- Header becomes slightly smaller and gains a stronger shadow after you scroll
- Works with the notch and safe areas on modern phones
- Accessible: labelled buttons,
aria-expanded, focus outlines and keyboard support - Respects the “reduce motion” setting
How to use it
- Open the HTML file and copy the
<header class="nav">block, the CSS inside theHEADERandMOBILEsections, and the script at the bottom. - Change the logo text and the links to your own pages.
- Replace the
href="#..."values with real page links, or keep them for a one-page site. - Change the two gradient colors
--g1and--g2at the top of the CSS to match your brand.
Why a floating header?
A floating header leaves a little space around it, so it feels lighter than a bar that touches the screen edges. The blur lets the page colors show through softly, which makes the header feel part of the design. On a phone, the same shape becomes a compact pill that does not cover much content.
Design tips
- Keep your top-level links to five or fewer.
- Make the main action button the only one with a strong color.
- On mobile, tap targets should be at least 44 pixels tall. Stellix Nav uses large rows for this reason.
- Test the dropdown with the Tab key, not just the mouse.
Frequently asked questions
Is Stellix Nav free? Yes, it is free to use.
Does it need a library? No. It uses plain HTML, CSS and JavaScript.
Can I use it in WordPress or React? Yes. Paste the HTML and CSS into a custom HTML block, or convert the markup into a component.
At what screen width does it switch to the mobile menu? At 880 pixels. You can change this number in the CSS and in the one matching line of JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Stellix Nav – Responsive Website Header (Mobile & Desktop) | Coding Stellix</title>
<meta name="description" content="Stellix Nav is a modern responsive website header by Coding Stellix. A floating glass bar on desktop, a smooth slide-down menu on mobile, dropdown, active link indicator and dark mode.">
<script>try{var t=localStorage.getItem("stxnav");document.documentElement.setAttribute("data-theme",t||(matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light"))}catch(e){document.documentElement.setAttribute("data-theme","light")}</script>
<style>
:root{--bg:#f5f4ff;--ink:#17163a;--mute:#5f5e86;--glass:rgba(255,255,255,.78);--line:rgba(110,100,220,.18);--pill:rgba(109,93,252,.12);--card:#fff;--g1:#6d5dfc;--g2:#ff6fb5;--shadow:0 12px 34px -16px rgba(60,40,160,.35);color-scheme:light;box-sizing:border-box}
:root[data-theme="dark"]{--bg:#0d0c1d;--ink:#f1f0ff;--mute:#a4a2d0;--glass:rgba(24,22,48,.74);--line:rgba(160,150,255,.2);--pill:rgba(140,125,255,.2);--card:#16152f;--shadow:0 14px 40px -14px rgba(0,0,0,.7);color-scheme:dark}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;background:var(--bg);color:var(--ink);font-family:"Segoe UI","Trebuchet MS",Arial,sans-serif;line-height:1.55;transition:background .3s}
a{color:inherit}
/* ===== HEADER ===== */
.nav{position:fixed;top:max(14px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);width:min(1120px,calc(100% - 24px));z-index:50;border-radius:22px;background:var(--glass);backdrop-filter:blur(16px) saturate(160%);-webkit-backdrop-filter:blur(16px) saturate(160%);border:1px solid var(--line);box-shadow:var(--shadow);transition:top .3s,box-shadow .3s}
.nav.scrolled{top:max(8px,env(safe-area-inset-top))}
.bar{display:flex;align-items:center;gap:14px;padding:9px 10px 9px 14px}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:800;font-size:18px;letter-spacing:-.3px}
.brand svg{flex:none}
.brand span b{background:linear-gradient(90deg,var(--g1),var(--g2));-webkit-background-clip:text;background-clip:text;color:transparent}
.links{list-style:none;margin:0 0 0 auto;padding:0;display:flex;gap:2px;position:relative;isolation:isolate}
.l{position:relative;z-index:1;font:inherit;font-size:15px;font-weight:600;color:var(--mute);background:none;border:0;text-decoration:none;padding:9px 14px;border-radius:12px;cursor:pointer;display:flex;align-items:center;gap:6px;transition:color .2s}
.l:hover,.l.on{color:var(--ink)}
.ind{position:absolute;left:0;top:0;height:100%;border-radius:12px;background:var(--pill);transition:transform .35s cubic-bezier(.3,.9,.3,1),width .35s cubic-bezier(.3,.9,.3,1),opacity .2s;opacity:0;z-index:0}
.has li,.has{position:relative}
.chev{transition:transform .25s}
.has:hover .chev,.has:focus-within .chev{transform:rotate(180deg)}
.dd{position:absolute;top:calc(100% + 14px);left:-40px;width:310px;padding:10px;border-radius:18px;background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow);opacity:0;visibility:hidden;transform:translateY(8px);transition:opacity .22s,transform .22s,visibility .22s}
.has::after{content:"";position:absolute;left:0;right:0;top:100%;height:16px}
.has:hover .dd,.has:focus-within .dd{opacity:1;visibility:visible;transform:none}
.dd a{display:flex;gap:12px;padding:10px;border-radius:12px;text-decoration:none}
.dd a:hover{background:var(--pill)}
.dd i{width:36px;height:36px;border-radius:11px;flex:none;display:grid;place-items:center;color:#fff;font-style:normal;font-weight:800;background:linear-gradient(135deg,var(--g1),var(--g2))}
.dd b{display:block;font-size:15px}
.dd small{color:var(--mute);font-size:13px;line-height:1.3;display:block}
.tools{display:flex;align-items:center;gap:8px;margin-left:8px}
.ic{width:40px;height:40px;border-radius:12px;border:1px solid var(--line);background:none;color:var(--ink);cursor:pointer;display:grid;place-items:center}
.ic:hover{background:var(--pill)}
.cta{font-weight:700;font-size:15px;text-decoration:none;color:#fff;padding:10px 20px;border-radius:13px;background:linear-gradient(135deg,var(--g1),var(--g2));box-shadow:0 8px 18px -8px var(--g1);transition:transform .15s}
.cta:hover{transform:translateY(-1px)}
.sun{display:none}
:root[data-theme="dark"] .sun{display:block}
:root[data-theme="dark"] .moon{display:none}
.burger{display:none}
.burger span{display:block;width:18px;height:2px;background:currentColor;border-radius:2px;transition:transform .3s,opacity .2s}
.burger span+span{margin-top:4px}
.open .burger span:nth-child(1){transform:translateY(6px) rotate(45deg)}
.open .burger span:nth-child(2){opacity:0}
.open .burger span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}
.sheet{display:none}
a:focus-visible,button:focus-visible{outline:3px solid var(--g1);outline-offset:2px}
/* ===== MOBILE ===== */
@media(max-width:880px){
.links,.tools .cta{display:none}
.tools{margin-left:auto}
.burger{display:grid;align-content:center;justify-items:center}
.sheet{display:block;position:absolute;left:0;right:0;top:calc(100% + 8px);padding:10px;border-radius:22px;background:var(--glass);backdrop-filter:blur(18px) saturate(160%);-webkit-backdrop-filter:blur(18px) saturate(160%);border:1px solid var(--line);box-shadow:var(--shadow);max-height:calc(100vh - 100px);overflow:auto;opacity:0;visibility:hidden;transform:translateY(-10px) scale(.98);transform-origin:top right;transition:opacity .25s,transform .25s,visibility .25s}
.open .sheet{opacity:1;visibility:visible;transform:none}
.sheet a.m,.sheet button.m{font:inherit;font-size:18px;font-weight:700;color:var(--ink);background:none;border:0;width:100%;text-align:left;text-decoration:none;display:flex;align-items:center;justify-content:space-between;padding:14px 12px;border-radius:14px;cursor:pointer}
.sheet a.m:active,.sheet button.m:active,.sheet a.m.on{background:var(--pill)}
.sub{max-height:0;overflow:hidden;transition:max-height .3s;padding-left:10px}
.sub.show{max-height:260px}
.sub a{display:block;text-decoration:none;color:var(--mute);font-weight:600;padding:10px 12px;border-radius:12px}
.sub a:active{background:var(--pill)}
.sheet .cta{display:block;text-align:center;margin:10px 4px 4px;padding:14px}
.m .chev{transition:transform .25s}
.m[aria-expanded="true"] .chev{transform:rotate(180deg)}
}
/* ===== DEMO PAGE ===== */
.hero{min-height:100vh;display:grid;place-items:center;text-align:center;padding:120px 20px 60px;background:radial-gradient(60% 50% at 20% 10%,rgba(109,93,252,.22),transparent 70%),radial-gradient(50% 40% at 85% 25%,rgba(255,111,181,.2),transparent 70%)}
.hero h1{margin:0 0 12px;font-size:clamp(34px,7vw,66px);letter-spacing:-1.5px;line-height:1.05;max-width:16ch;margin-inline:auto}
.hero p{margin:0 auto;max-width:48ch;color:var(--mute);font-size:18px}
.hero small{display:block;margin-top:18px;color:var(--mute)}
section.s{min-height:70vh;max-width:900px;margin:auto;padding:90px 22px;scroll-margin-top:60px}
section.s h2{font-size:clamp(28px,5vw,40px);margin:0 0 10px;letter-spacing:-1px}
section.s p{color:var(--mute);font-size:17px;max-width:56ch}
@media(prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto!important}}
</style>
</head>
<body>
<!-- Stellix Nav by Coding Stellix -->
<header class="nav" id="hd">
<div class="bar">
<a class="brand" href="#home" aria-label="Coding Stellix home">
<svg width="34" height="34" viewBox="0 0 34 34" aria-hidden="true"><defs><linearGradient id="lg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff6fb5"/></linearGradient></defs><rect width="34" height="34" rx="10" fill="url(#lg)"/><path d="M17 6l2.6 7.4L27 16l-7.4 2.6L17 26l-2.6-7.4L7 16l7.4-2.6z" fill="#fff"/></svg>
<span>Coding <b>Stellix</b></span></a>
<ul class="links" id="links">
<span class="ind" id="ind"></span>
<li><a class="l" data-s="home" href="#home">Home</a></li>
<li class="has"><button class="l" data-s="services" aria-haspopup="true">Services <svg class="chev" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M2 4l4 4 4-4"/></svg></button>
<div class="dd"><a href="#services"><i>W</i><span><b>Web Design</b><small>Clean, fast websites that look great.</small></span></a><a href="#services"><i>A</i><span><b>Web Apps</b><small>Tools and games built with JavaScript.</small></span></a><a href="#services"><i>C</i><span><b>Content</b><small>Tutorials, reels and blog posts.</small></span></a></div></li>
<li><a class="l" data-s="projects" href="#projects">Projects</a></li>
<li><a class="l" data-s="blog" href="#blog">Blog</a></li>
<li><a class="l" data-s="about" href="#about">About</a></li>
</ul>
<div class="tools">
<button class="ic" id="th" aria-label="Toggle dark mode"><svg class="moon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 13A9 9 0 1 1 11 3a7 7 0 0 0 10 10z"/></svg><svg class="sun" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5L19 19M5 19l1.5-1.5M17.5 6.5L19 5"/></svg></button>
<a class="cta" href="#about">Get Started</a>
<button class="ic burger" id="bg" aria-label="Open menu" aria-expanded="false" aria-controls="sh"><span></span><span></span><span></span></button>
</div>
</div>
<nav class="sheet" id="sh" aria-label="Mobile">
<a class="m" href="#home">Home</a>
<button class="m" id="sv" aria-expanded="false">Services <svg class="chev" width="14" height="14" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M2 4l4 4 4-4"/></svg></button>
<div class="sub" id="sb"><a href="#services">Web Design</a><a href="#services">Web Apps</a><a href="#services">Content</a></div>
<a class="m" href="#projects">Projects</a>
<a class="m" href="#blog">Blog</a>
<a class="m" href="#about">About</a>
<a class="cta" href="#about">Get Started</a>
</nav>
</header>
<main>
<div class="hero" id="home"><div><h1>A header that fits every screen</h1><p>Floating glass bar on desktop. Smooth slide-down menu on mobile. Resize this window or open it on your phone.</p><small>Scroll down to see the active link move.</small></div></div>
<section class="s" id="services"><h2>Services</h2><p>Hover Services in the header on desktop to see the dropdown. On mobile, open the menu and tap Services to expand it.</p></section>
<section class="s" id="projects"><h2>Projects</h2><p>The highlight pill slides to the link you hover and rests on the section you are viewing.</p></section>
<section class="s" id="blog"><h2>Blog</h2><p>The header shrinks a little and gets a stronger shadow once you scroll.</p></section>
<section class="s" id="about"><h2>About</h2><p>Try the moon button for dark mode. Your choice is remembered on this device.</p></section>
</main>
<script>
var $=function(i){return document.getElementById(i)},hd=$("hd"),ind=$("ind"),act=null;
var secs=["home","services","projects","blog","about"],ls={};
[].forEach.call(document.querySelectorAll(".links .l"),function(l){ls[l.dataset.s]=l});
function mv(el){if(!el){ind.style.opacity=0;return}var a=$("links").getBoundingClientRect(),b=el.getBoundingClientRect();ind.style.opacity=1;ind.style.width=b.width+"px";ind.style.transform="translateX("+(b.left-a.left)+"px)"}
function setAct(n){act=ls[n]||null;Object.keys(ls).forEach(function(k){ls[k].classList.toggle("on",k==n)});mv(act)}
Object.keys(ls).forEach(function(k){var l=ls[k];l.addEventListener("mouseenter",function(){mv(l)});l.addEventListener("focus",function(){mv(l)})});
$("links").addEventListener("mouseleave",function(){mv(act)});
var io=new IntersectionObserver(function(es){es.forEach(function(e){if(e.isIntersecting)setAct(e.target.id)})},{rootMargin:"-40% 0px -55% 0px"});
secs.forEach(function(s){io.observe($(s))});
window.addEventListener("resize",function(){mv(act)});
addEventListener("scroll",function(){hd.classList.toggle("scrolled",scrollY>20)},{passive:true});
function menu(o){hd.classList.toggle("open",o);$("bg").setAttribute("aria-expanded",o);$("bg").setAttribute("aria-label",o?"Close menu":"Open menu")}
$("bg").onclick=function(){menu(!hd.classList.contains("open"))};
$("sv").onclick=function(){var o=$("sb").classList.toggle("show");$("sv").setAttribute("aria-expanded",o)};
[].forEach.call($("sh").querySelectorAll("a"),function(a){a.addEventListener("click",function(){menu(false)})});
document.addEventListener("keydown",function(e){if(e.key=="Escape")menu(false)});
document.addEventListener("click",function(e){if(hd.classList.contains("open")&&!hd.contains(e.target))menu(false)});
matchMedia("(min-width:881px)").addEventListener("change",function(m){if(m.matches)menu(false)});
$("th").onclick=function(){var r=document.documentElement,n=r.getAttribute("data-theme")=="dark"?"light":"dark";r.setAttribute("data-theme",n);try{localStorage.setItem("stxnav",n)}catch(e){}};
setAct("home");
</script>
</body>
</html>