10 CSS Parallax Effects 05 / 10

CSS Parallax Image Grid / Gallery

Twelve-cell asymmetric CSS Grid portfolio where each cell's inner layer translateY at speeds from 0.10× to 0.38× on scroll — creating subtle but convincing photo drift inside bounded containers. Abstract colour-field fills, hover captions, filter tab bar. Syne + Syne Mono. Clean white gallery aesthetic punctuated by oversized index numerals.

CSS + JS MIT licensed
Live Demo Open in tab

This is a full-page demo — interact inside the frame above, or open it in the playground for the full-screen experience.

Open in playground

The code

<div class="plx-05">

  <header class="plx-05__header">
    <span class="plx-05__brand">Forma Gallery</span>
    <span class="plx-05__tagline">12 works / parallax grid</span>
  </header>

  <div class="plx-05__hero-text">
    <h1>A gallery<br>built on <em>depth</em><br>&amp; movement.</h1>
  </div>

  <div class="plx-05__filters">
    <button class="plx-05__filter is-active">All Works</button>
    <button class="plx-05__filter">Abstract</button>
    <button class="plx-05__filter">Landscape</button>
    <button class="plx-05__filter">Portrait</button>
    <button class="plx-05__filter">Editorial</button>
  </div>

  <div class="plx-05__count">Showing 12 of 12 works</div>

  <div class="plx-05__grid" id="plx05-grid">

    <div class="plx-05__cell" data-speed="0.18">
      <div class="plx-05__inner"></div>
      <span class="plx-05__badge">Featured</span>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Terracotta Dawn</span>
        <span class="plx-05__caption-sub">Abstract · 2024 · Oil on linen</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.25">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Verde Study I</span>
        <span class="plx-05__caption-sub">Landscape · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.12">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Midnight Architecture</span>
        <span class="plx-05__caption-sub">Editorial · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.32">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Mauve Hour</span>
        <span class="plx-05__caption-sub">Abstract · 2023</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.2">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Sand Drift</span>
        <span class="plx-05__caption-sub">Landscape · 2023</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.38">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Void</span>
        <span class="plx-05__caption-sub">Minimal · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.15">
      <div class="plx-05__inner"></div>
      <span class="plx-05__badge">New</span>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Forest Floor</span>
        <span class="plx-05__caption-sub">Landscape · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.28">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Pale Geometry</span>
        <span class="plx-05__caption-sub">Abstract · 2023</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.1">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Chromatic Wheel</span>
        <span class="plx-05__caption-sub">Abstract · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.35">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Ember Study</span>
        <span class="plx-05__caption-sub">Portrait · 2023</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.22">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Ochre Valley</span>
        <span class="plx-05__caption-sub">Landscape · 2024</span>
      </div>
    </div>

    <div class="plx-05__cell" data-speed="0.16">
      <div class="plx-05__inner"></div>
      <div class="plx-05__caption">
        <span class="plx-05__caption-title">Teal Descent</span>
        <span class="plx-05__caption-sub">Abstract · 2024</span>
      </div>
    </div>

  </div>

</div>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.plx-05 {
  --ink: #0d0d0d;
  --paper: #f2ede7;
  --sand: #d4c4a8;
  --terracotta: #c4623a;
  --sage: #7a9e7e;
  --navy: #1e2d45;
  --lavender: #8b7ec8;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Syne', sans-serif;
  overflow-x: hidden;
}

/* ── Header ── */
.plx-05__header {
  padding: 80px 60px 60px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid rgba(13,13,13,0.12);
}

.plx-05__brand {
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.plx-05__tagline {
  font-family: 'Syne Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.45;
}

/* ── Hero text ── */
.plx-05__hero-text {
  padding: 80px 60px 0;
}

.plx-05__hero-text h1 {
  font-size: clamp(52px, 10vw, 130px);
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: -0.03em;
  max-width: 900px;
}

.plx-05__hero-text h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--terracotta);
}

/* ── Masonry-style grid ── */
.plx-05__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 80px;
  gap: 16px;
  padding: 60px 60px;
}

/* Each cell is a parallax image container */
.plx-05__cell {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-radius: 4px;
}

/* Cell size variations */
.plx-05__cell:nth-child(1)  { grid-column: 1 / 6;  grid-row: 1 / 7; }
.plx-05__cell:nth-child(2)  { grid-column: 6 / 9;  grid-row: 1 / 5; }
.plx-05__cell:nth-child(3)  { grid-column: 9 / 13; grid-row: 1 / 6; }
.plx-05__cell:nth-child(4)  { grid-column: 6 / 9;  grid-row: 5 / 9; }
.plx-05__cell:nth-child(5)  { grid-column: 9 / 12; grid-row: 6 / 10; }
.plx-05__cell:nth-child(6)  { grid-column: 12 / 13; grid-row: 6 / 11; }
.plx-05__cell:nth-child(7)  { grid-column: 1 / 5;  grid-row: 7 / 12; }
.plx-05__cell:nth-child(8)  { grid-column: 5 / 9;  grid-row: 9 / 13; }
.plx-05__cell:nth-child(9)  { grid-column: 9 / 13; grid-row: 10 / 14; }
.plx-05__cell:nth-child(10) { grid-column: 1 / 4;  grid-row: 12 / 15; }
.plx-05__cell:nth-child(11) { grid-column: 4 / 9;  grid-row: 13 / 17; }
.plx-05__cell:nth-child(12) { grid-column: 9 / 13; grid-row: 14 / 18; }

/* Inner element that moves with parallax. inset: -40% gives the
   inner 40% extra on every side beyond the cell, providing buffer
   for the JS translateY without revealing the cell's edge.
   (Previously -25% which clipped at extreme scroll positions.) */
.plx-05__inner {
  position: absolute;
  inset: -40%;
  will-change: transform;
  background-size: cover;
  background-position: center;
  transition: filter 0.5s;
}

/* Color-based abstract fills (no real images) */
.plx-05__cell:nth-child(1)  .plx-05__inner { background: linear-gradient(145deg, #c4623a 0%, #8b3a1e 50%, #1e2d45 100%); }
.plx-05__cell:nth-child(2)  .plx-05__inner { background: linear-gradient(200deg, #7a9e7e 0%, #4a7a4e 70%); }
.plx-05__cell:nth-child(3)  .plx-05__inner { background: linear-gradient(110deg, #1e2d45 0%, #2a4070 50%, #8b7ec8 100%); }
.plx-05__cell:nth-child(4)  .plx-05__inner { background: radial-gradient(circle at 40% 60%, #8b7ec8 0%, #4a3a80 100%); }
.plx-05__cell:nth-child(5)  .plx-05__inner { background: linear-gradient(160deg, #d4c4a8 0%, #c4623a 100%); }
.plx-05__cell:nth-child(6)  .plx-05__inner { background: linear-gradient(180deg, #0d0d0d, #2a2a2a); }
.plx-05__cell:nth-child(7)  .plx-05__inner { background: radial-gradient(ellipse at 60% 40%, #7a9e7e 0%, #1e2d1e 100%); }
.plx-05__cell:nth-child(8)  .plx-05__inner { background: linear-gradient(135deg, #f2ede7 0%, #d4c4a8 40%, #c4623a 100%); }
.plx-05__cell:nth-child(9)  .plx-05__inner { background: conic-gradient(from 30deg, #1e2d45, #8b7ec8, #c4623a, #1e2d45); }
.plx-05__cell:nth-child(10) .plx-05__inner { background: linear-gradient(200deg, #c4623a 0%, #7a4020 100%); }
.plx-05__cell:nth-child(11) .plx-05__inner { background: radial-gradient(circle at 30% 70%, #d4c4a8 0%, #8b6a40 100%); }
.plx-05__cell:nth-child(12) .plx-05__inner { background: linear-gradient(160deg, #0d0d0d 0%, #1e2d45 50%, #7a9e7e 100%); }

/* Geometric overlays on inner */
.plx-05__inner::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.15;
}
.plx-05__cell:nth-child(odd) .plx-05__inner::after {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.1) 0px, rgba(255,255,255,0.1) 1px, transparent 1px, transparent 20px);
}
.plx-05__cell:nth-child(even) .plx-05__inner::after {
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2) 0%, transparent 60%);
}

/* Overlay caption */
.plx-05__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 18px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s, transform 0.35s;
  z-index: 2;
}

.plx-05__cell:hover .plx-05__caption {
  opacity: 1;
  transform: translateY(0);
}

.plx-05__caption-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #fff;
  display: block;
}

.plx-05__caption-sub {
  font-family: 'Syne Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
}

/* Badge on a few cells */
.plx-05__badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  font-family: 'Syne Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  z-index: 3;
  border-radius: 2px;
}

/* Hover scale on entire cell */
.plx-05__cell {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.plx-05__cell:hover {
  transform: scale(1.02);
  z-index: 10;
}

/* ── Filters row ── */
.plx-05__filters {
  display: flex;
  gap: 8px;
  padding: 0 60px 40px;
  flex-wrap: wrap;
}

.plx-05__filter {
  padding: 7px 18px;
  font-family: 'Syne Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(13,13,13,0.2);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--ink);
}

.plx-05__filter.is-active,
.plx-05__filter:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ── Count ── */
.plx-05__count {
  padding: 0 60px 20px;
  font-family: 'Syne Mono', monospace;
  font-size: 11px;
  opacity: 0.4;
  letter-spacing: 0.1em;
}

@media (max-width: 900px) {
  .plx-05__grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 100px;
    padding: 30px;
  }
  .plx-05__cell:nth-child(1)  { grid-column: 1 / 3; grid-row: 1 / 4; }
  .plx-05__cell:nth-child(2)  { grid-column: 3 / 5; grid-row: 1 / 3; }
  .plx-05__cell:nth-child(3)  { grid-column: 3 / 5; grid-row: 3 / 5; }
  .plx-05__cell:nth-child(4)  { grid-column: 1 / 3; grid-row: 4 / 6; }
  .plx-05__cell:nth-child(5)  { grid-column: 3 / 5; grid-row: 5 / 7; }
  .plx-05__cell:nth-child(6)  { grid-column: 1 / 3; grid-row: 6 / 8; }
  .plx-05__cell:nth-child(7)  { grid-column: 3 / 5; grid-row: 7 / 9; }
  .plx-05__cell:nth-child(8)  { grid-column: 1 / 3; grid-row: 8 / 10; }
  .plx-05__cell:nth-child(9)  { grid-column: 3 / 5; grid-row: 9 / 11; }
  .plx-05__cell:nth-child(10) { grid-column: 1 / 3; grid-row: 10 / 12; }
  .plx-05__cell:nth-child(11) { grid-column: 3 / 5; grid-row: 11 / 13; }
  .plx-05__cell:nth-child(12) { grid-column: 1 / 5; grid-row: 13 / 15; }
  .plx-05__header, .plx-05__hero-text, .plx-05__filters, .plx-05__count { padding-left: 30px; padding-right: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .plx-05__inner { will-change: auto; transform: translateY(0) !important; }
  .plx-05__cell { transition: none; }
  .plx-05__caption { transition: none; }
}
(() => {
  const root = document.querySelector('.plx-05');
  if (!root) return;

  // Skip parallax entirely for visitors who prefer reduced motion.
  // The grid remains visible and scrollable; just no transform updates.
  if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;

  const cells = Array.from(root.querySelectorAll('.plx-05__cell[data-speed]')).map(el => ({
    el,
    inner: el.querySelector('.plx-05__inner'),
    speed: parseFloat(el.dataset.speed)
  }));

  // Multiplier applied to every cell's data-speed. Original speeds
  // (0.10-0.38 from the data attributes) produced too-subtle motion
  // — visitors reported "no effect" because cell-relative drift was
  // barely perceptible. ×2.5 gives roughly ±60-200px of inner
  // translation across the viewport traversal, which is clearly
  // visible without overrunning the new -40% inner buffer.
  const BOOST = 2.5;

  let ticking = false;

  function onScroll() {
    if (ticking) return;
    ticking = true;
    requestAnimationFrame(() => {
      const viewH = window.innerHeight;
      cells.forEach(({ el, inner, speed }) => {
        const rect = el.getBoundingClientRect();
        const centerY = rect.top + rect.height / 2 - viewH / 2;
        if (inner) inner.style.transform = `translateY(${centerY * speed * BOOST * -1}px)`;
      });
      ticking = false;
    });
  }

  // Filter buttons (visual only)
  const filters = Array.from(root.querySelectorAll('.plx-05__filter'));
  filters.forEach(btn => {
    btn.addEventListener('click', () => {
      filters.forEach(b => b.classList.remove('is-active'));
      btn.classList.add('is-active');
    });
  });

  window.addEventListener('scroll', onScroll, { passive: true });
  onScroll();
})();

Search CodeFronts

Loading…