Preview

Simulates a glassmorphic fixed navigator with scrolling. Click the button in the preview to see the scrolling effect.

Content area 1 — Please scroll down
Content area 2
Content area 3
Content area 4

Use cases and features

Points of design and UX

  1. Fires at scroll 10px: Glass morphism appears at neutral timing.

  2. Change in padding: Reduced from 1.25rem to 0.75rem to make it more compact and secure a wider content area.

  3. Smooth with transition: Create natural changes by simultaneously transitioning the four properties of background, blur, box-shadow, and padding.

How to customize

Change scroll start threshold:


// trigger earlier (5px)

if (demo.scrollTop > 5) { ... }



// trigger later (50px)

if (demo.scrollTop > 50) { ... }

add link:


<li><a href="#services">service</a></li>

<li><a href="#blog">Blog</a></li>

Implementation code

<nav class="snav-bar" id="sticky-nav">

<div class="snav-logo">BRAND</div>

<ul class="snav-links">

  <li><a href="#">Home</a></li>

  <li><a href="#">About</a></li>

  <li><a href="#">Work</a></li>

</ul>

<button class="snav-cta">Contact</button>

</nav>



<style>
.snav-bar {

position: sticky;

top: 0;

z-index: 100;

width: 100%;

box-sizing: border-box;

padding: 1.25rem 2rem;

display: flex;

align-items: center;

justify-content: space-between;

gap: 1.5rem;

transition: background 0.3s ease, backdrop-filter 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease;

}

.snav-bar.scrolled {

background: rgba(15,23,42,0.75);

backdrop-filter: blur(16px);

box-shadow: 0 1px 0 rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.4);

padding: 0.75rem 2rem;

}
</style>



<script>

window.addEventListener('scroll', function() {

var nav = document.getElementById('sticky-nav');

if (window.scrollY > 10) nav.classList.add('scrolled');

else nav.classList.remove('scrolled');

});

</script>

Browser compatibility status

| Browser | Compatibility status |

|--------|-------|

| Chrome 76+ | ✅ Fully compatible |

| Firefox 103+ | ✅ Compatible |

| Safari 9+ | ✅ Fully compatible |

| Edge 79+ | ✅ Fully compatible |

backdrop-filter is not supported by some older browsers, but a semi-transparent background of background: rgba(...) is sufficient as a fallback.