AI CSS Animations

Striped Shadow Text

Solid letters cast an offset shadow made of fine diagonal lines that scroll and breathe, the screen-printed look of retro posters. The shadow is a stacked copy with a tiled stripe clipped to it.

Also known as: hatched text shadow css, retro line shadow text, diagonal stripe shadow.

RETRO

HTML

<div class="txt-striped-shadow-text"><span class="txt-striped-shadow-text-shadow" aria-hidden="true">RETRO</span><span>RETRO</span></div>

CSS

.txt-striped-shadow-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.7);
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-weight: 900;
  line-height: 1.2;
  display: inline-grid;
  color: var(--c);}
.txt-striped-shadow-text > span {
  grid-area: 1 / 1;
}
/* 45 degree stripes in a square tile repeat seamlessly, so one tile of travel loops */
.txt-striped-shadow-text-shadow {
  background: linear-gradient(-45deg, var(--c) 0 16%, transparent 16% 50%, var(--c) 50% 66%, transparent 66%) 0 0 / 0.16em 0.16em;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  transform: translate(0.08em, 0.08em);
  animation:
    txt-striped-shadow-text-scroll 0.9s linear infinite,
    txt-striped-shadow-text-shift 3s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
@keyframes txt-striped-shadow-text-scroll {
  to { background-position: 0.16em 0; }
}
@keyframes txt-striped-shadow-text-shift {
  from { transform: translate(0.05em, 0.05em); }
  to   { transform: translate(0.11em, 0.11em); }
}

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