Skip to content

Parallax Layer

A copy-paste scroll-driven component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Scroll-DrivenHTMLCSSany framework

Foreground

Copy into your project

HTML
<div class="nuda-scrollpx__viewport">
  <div class="nuda-scrollpx__layer nuda-scrollpx__layer--back">BG</div>
  <div class="nuda-scrollpx__layer nuda-scrollpx__layer--mid"></div>
  <div class="nuda-scrollpx__scroller">
    <p class="nuda-scrollpx__fore">Foreground</p>
  </div>
</div>
CSS
/* Parallax Layer
   Background layers translate at different rates from the foreground
   using a shared scroll() timeline. transform only (GPU). */

.nuda-scrollpx__viewport { position: relative; height: 100%; }

.nuda-scrollpx__scroller {
  position: relative;
  height: 100%;
  overflow: auto;
  z-index: 2;
}

.nuda-scrollpx__fore {
  text-align: center;
  color: #e4ff54;
  font-weight: 700;
}

.nuda-scrollpx__layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.nuda-scrollpx__layer--back {
  animation: nuda-scrollpx-back linear;
  animation-timeline: scroll(nearest block);
}

.nuda-scrollpx__layer--mid {
  background: radial-gradient(circle at 50% 40%,
              rgba(228, 255, 84, 0.1), transparent 60%);
  animation: nuda-scrollpx-mid linear;
  animation-timeline: scroll(nearest block);
}

@keyframes nuda-scrollpx-back { to { transform: translateY(-24px); } }
@keyframes nuda-scrollpx-mid  { to { transform: translateY(-48px); } }

@supports not (animation-timeline: scroll()) {
  .nuda-scrollpx__layer--back,
  .nuda-scrollpx__layer--mid { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nuda-scrollpx__layer--back,
  .nuda-scrollpx__layer--mid {
    animation: none;
    animation-timeline: none;
    transform: none;
  }
}

How to use Parallax Layer

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More scroll-driven components

← Browse all NudaUI components