AI CSS Animations

Movie Trailer Title Text

Letters fade in from a blur and drift slowly apart while the title holds, then dissolve, like a trailer title card. Each letter moves by its distance from the middle, so only transforms animate.

Also known as: cinematic title animation css, letter spacing expand animation, trailer text effect.

COMING SOON

HTML

<div class="txt-movie-trailer-title" aria-label="COMING SOON"><span style="--i: 0; --o: -5">C</span><span style="--i: 1; --o: -4">O</span><span style="--i: 2; --o: -3">M</span><span style="--i: 3; --o: -2">I</span><span style="--i: 4; --o: -1">N</span><span style="--i: 5; --o: 0">G</span><span style="--i: 6; --o: 1">&nbsp;</span><span style="--i: 7; --o: 2">S</span><span style="--i: 8; --o: 3">O</span><span style="--i: 9; --o: 4">O</span><span style="--i: 10; --o: 5">N</span></div>

CSS

.txt-movie-trailer-title {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.1);
  font-family: system-ui, sans-serif;
  font-weight: 300;
  line-height: 1.2;
  display: inline-block;
  padding-left: 0.14em; /* balances the trailing letter-spacing */
  color: var(--c);
  letter-spacing: 0.14em;
  white-space: nowrap;}
.txt-movie-trailer-title span {
  display: inline-block;
  animation: txt-movie-trailer-title-drift 5s linear -1.2s infinite;
}
/* --o is the letter's distance from the middle: 0 at the center */
@keyframes txt-movie-trailer-title-drift {
  0%   { opacity: 0; filter: blur(0.12em); transform: translateX(calc(var(--o) * -0.03em)); }
  18%  { opacity: 1; filter: blur(0); }
  76%  { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(0.1em); transform: translateX(calc(var(--o) * 0.13em)); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-movie-trailer-title, .txt-movie-trailer-title *, .txt-movie-trailer-title::before, .txt-movie-trailer-title::after, .txt-movie-trailer-title *::before, .txt-movie-trailer-title *::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