Parallax Vinculado al Scroll in CSS: Profundidad a 120 FPS mit animation-timeline: view()

Schnellübersicht

Erstellen Effekte von profundidad parallax in die web tradicionalmente exigía capturar der scroll in JavaScript, provocando desincronización, calentamiento von CPU und micro-tirones constantes. Mit die especificación native von Scroll-Driven Animations von CSS, der desplazamiento vom Element in der viewport actúa wie Timeline directa mediante animation-timeline: view(). Desfasando die velocidades relativas mit translateY() in der hilo von die GPU, se consiguen 120 FPS mit cero líneas von Code JS.

Interaktive Demo Live-Vorschau
Multi-Plane Parallax Depth Simulation VIEW TIMELINE
Foreground: 1.0x Speed
animation-range: entry 0% exit 100% · 120 FPS

Schritt 1: Die Arquitectura von die Líneas von Tiempo view()

A diferencia von eine Animation temporal basada in segundos, eine Timeline view() progresa von 0% (der instante in que der Rahmen superior vom Element toca der Hintergrund vom viewport) bis 100% (wenn sale completamente durch der Rahmen superior).

view-timeline-base.css
@keyframes parallaxMove {
  from { transform: translateY(-40px); }
  to   { transform: translateY(40px); }
}

.parallax-layer {
  animation: parallaxMove linear both;
  animation-timeline: view();
}

Schritt 2: Calibración von Velocidades von Profundidad in Múltiples Planos

Die ilusión von profundidad tridimensional exige que die objetos mehr cercanos a die cámara se muevan mehr schnell que die objetos lejanos. Define 3 capas (Hintergrund, Element medio, primer plano) mit diferentes rangos von desplazamiento in translateY().

multiplane-parallax.css
/* Capa 1: Fondo Lejano (desplazamiento sutil) */
.layer-background {
  animation: bgShift linear both;
  animation-timeline: view();
}
@keyframes bgShift {
  from { transform: translateY(-15px); }
  to   { transform: translateY(15px); }
}

/* Capa 2: Primer Plano Cercano (desplazamiento acentuado) */
.layer-foreground {
  animation: fgShift linear both;
  animation-timeline: view();
}
@keyframes fgShift {
  from { transform: translateY(-70px); }
  to   { transform: translateY(70px); }
}

Schritt 3: Ajuste Fino von die Límites von animation-range

Controla mit exactitud in qué punto vom scroll debe comenzar und detenerse der movimiento. Für tarjetas que están a die vista vom Nutzer in der centro von die Bildschirm, nutzt animation-range: cover 0% cover 100%.

range-tuning.css
.smooth-card {
  animation: cardFloat linear both;
  animation-timeline: view();
  /* Sincronizado exactamente mientras el contenedor cruza el viewport */
  animation-range: cover 0% cover 100%;
}

@keyframes cardFloat {
  from { transform: translateY(30px) scale(0.96); opacity: 0.8; }
  to   { transform: translateY(-30px) scale(1.02); opacity: 1; }
}

Schritt 4: Respaldo für Browser Antiguos ohne Tirones von Scroll

Asegúrate von que in Browser que aún no soportan die Animationen von scroll der contenido permanezca visible und estático in su posición natural ohne romperse mediante die Regel @supports.

parallax-fallback.css
@supports not (animation-timeline: view()) {
  .parallax-layer,
  .layer-background,
  .layer-foreground {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-timeline: auto !important;
    animation: none !important;
  }
}

Erweiterte Best Practices & Vertiefung

Erweitere diese Implementierung durch die Kombination mit ergänzenden Werkzeugen und Design-Tokens:

Parallax: View Timeline Depth 120 FPS

1. Studio von Animationen von Scroll in CSS

Im Studio von Scroll Animation öffnen →

Testet interactivamente Timelines view() und calibración von rangos cover/entry in vivo.

Progress Bar Synced Compositor Thread Lock

2. Hintergründe Aurora und Mallas Animadas

Im Studio von Hintergründe Aurora öffnen →

Kombiniert escenas parallax mit Hintergründe von Farbverlauf flüssig Mehrschicht.

Volumetric Fog Layer Z-Index 2

3. Auditor von Performance und Jank von Animationen

Im Auditor von Animationen öffnen →

Verifiziert die tasa von 120 FPS in Bildschirme mit alta Frequenz von refresco.

Chaam
Chaams Profi-Tipp

Ein Trick, den ich in fast jedem Projekt nutze: Verliere dich nicht in Spezifitätskonflikten mit !important. Nutze moderne CSS-Cascade-Layers (@layer) und CSS-Variablen als Design-Tokens – das macht den Wechsel zwischen Dark- und Light-Theme extrem sauber.

Deseas gestalten escenas von profundidad parallax ohne JavaScript?

Generiert planos multicapa von desplazamiento relativo mit calibración visuell von rangos und exportación limpia.

Im Studio von Animationen von Scroll öffnen ↗

Häufig gestellte Fragen (FAQ)

Praxisnahe Antworten zu Implementierung, Browser-Besonderheiten und Performance-Tipps.

Durch qué der parallax mit animation-timeline es mucho mehr suave que mit JavaScript?

Die listeners von scroll in JavaScript se ejecutan in der Haupt-Thread vom Browser. Si hay scripts pesados procesándose, die tasa von fotogramas cae a 30-40 FPS provocando tirones. Die Animationen vinculadas al scroll in CSS se ejecutan directamente in der compositor von die GPU a 60 oder 120 FPS ohne Latenz von JavaScript.

Qué Browser soportan actualmente animation-timeline: view()?

Todos die Browser basados in Chromium (Google Chrome, Microsoft Edge, Opera, Brave) soportan die especificación nativamente von die versión 115. Der motor von Safari und Firefox die tienen implementada in versiones von desarrollo.

Wie man evita que die Bilder mit Effekt parallax se corten in die Rahmen?

Asegurando que die Bild sea ligeramente mehr alta que su contenedor (durch Beispiel, height: 120%) und aplicando object-fit: cover;, von modo que der desplazamiento vertical in translateY() siempre tenga píxeles excedentes que mostrar.

Qué función cumple die palabra clave both in animation: ... linear both?

both kombiniert animation-fill-mode: backwards und forwards. Dies asegura que antes von entrar al rango aktiv der Element ya adopte die Stile vom fotograma inicial und al salir retenga die vom fotograma final.

Wie debe gestionarse die accesibilidad von movimiento in escenas parallax?

Der desplazamiento parallax puede provocar mareos und náuseas espaciales in personas mit desórdenes vestibulares. Es imperativo incluir @media (prefers-reduced-motion: reduce) desactivando die Animation für anclar todos die planos.

← Zurück zu allen Blog-Artikeln Generator-Studio starten →