AI CSS Animations

Layered 3D Text Effect

Five copies of the word at different depths, each shifted in hue, sway in 3D so the layers fan apart like a paper cut. Two nested rotations on different timings trace a smooth figure eight.

Also known as: stacked text layers css, paper cut text effect, parallax 3d text.

HTML

<div class="txt-layered-3d-text" aria-label="LAYERS"><span class="txt-layered-3d-text-tilt" aria-hidden="true"><span class="txt-layered-3d-text-stack"><span style="--i: 0">LAYERS</span><span style="--i: 1">LAYERS</span><span style="--i: 2">LAYERS</span><span style="--i: 3">LAYERS</span><span style="--i: 4">LAYERS</span></span></span></div>

CSS

.txt-layered-3d-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.7);
  font-family: system-ui, sans-serif;
  font-weight: 900;
  line-height: 1.2;
  display: inline-block;
  perspective: 10em;
  letter-spacing: 0.02em;}
.txt-layered-3d-text-tilt,
.txt-layered-3d-text-stack {
  display: grid;
  transform-style: preserve-3d;
}
.txt-layered-3d-text-tilt {
  animation: txt-layered-3d-text-pitch 3s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.txt-layered-3d-text-stack {
  animation: txt-layered-3d-text-yaw 6s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
/* layer 0 in front; each one behind is pushed back and turned on the color wheel */
.txt-layered-3d-text-stack span {
  grid-area: 1 / 1;
  color: var(--c);
  filter: hue-rotate(calc(var(--i) * 40deg));
  transform: translateZ(calc(var(--i) * -0.2em));
}
@keyframes txt-layered-3d-text-pitch {
  from { transform: rotateX(14deg); }
  to   { transform: rotateX(-10deg); }
}
@keyframes txt-layered-3d-text-yaw {
  from { transform: rotateY(-28deg); }
  to   { transform: rotateY(28deg); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-layered-3d-text, .txt-layered-3d-text *, .txt-layered-3d-text::before, .txt-layered-3d-text::after, .txt-layered-3d-text *::before, .txt-layered-3d-text *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations