AI CSS Animations

Star Wars Text Crawl

Story text scrolls up a tilted plane and shrinks toward a vanishing point, like a space opera's opening crawl. A rotateX plane inside a perspective box, faded out at the far end with a mask.

Also known as: opening crawl css, star wars intro text css, perspective scrolling text.

Episode IV

A NEW RELEASE

It is a period of shipping. Rebel developers, striking from a hidden branch, have won their first victory against the dreaded Legacy Monolith.

During the battle, they stole the plans to the Monolith's ultimate weapon: a build that takes forty minutes.

HTML

<div class="txt-star-wars-text-crawl">
  <div class="txt-star-wars-text-crawl-plane">
    <div class="txt-star-wars-text-crawl-text">
      <p class="txt-star-wars-text-crawl-episode">Episode IV</p>
      <p class="txt-star-wars-text-crawl-heading">A NEW RELEASE</p>
      <p>It is a period of shipping. Rebel developers, striking from a hidden branch, have won their first victory against the dreaded Legacy Monolith.</p>
      <p>During the battle, they stole the plans to the Monolith's ultimate weapon: a build that takes forty minutes.</p>
    </div>
  </div>
</div>

CSS

.txt-star-wars-text-crawl {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  position: relative;
  width: 11em;
  height: 5.4em;
  overflow: hidden;
  perspective: 7em;
  perspective-origin: 50% 0;
  color: var(--c);
  -webkit-mask-image: linear-gradient(transparent 5%, #000 60%);
  mask-image: linear-gradient(transparent 5%, #000 60%);}
/* the floor the text slides along, tipped back from its bottom edge */
.txt-star-wars-text-crawl-plane {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 9em;
  height: 12em;
  margin-left: -4.5em;
  transform-origin: 50% 100%;
  transform: rotateX(58deg);
}
.txt-star-wars-text-crawl-text {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  font-size: 0.55em;
  line-height: 1.35;
  text-align: justify;
  animation: txt-star-wars-text-crawl-roll 15s linear -4s infinite;
}
.txt-star-wars-text-crawl-text p {
  margin: 0 0 0.9em;
}
.txt-star-wars-text-crawl-episode,
.txt-star-wars-text-crawl-heading {
  text-align: center;
}
.txt-star-wars-text-crawl-heading {
  font-size: 1.5em;
  letter-spacing: 0.08em;
}
@keyframes txt-star-wars-text-crawl-roll {
  from { transform: translateY(0); }
  to   { transform: translateY(calc(-100% - 10em)); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-star-wars-text-crawl, .txt-star-wars-text-crawl *, .txt-star-wars-text-crawl::before, .txt-star-wars-text-crawl::after, .txt-star-wars-text-crawl *::before, .txt-star-wars-text-crawl *::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