AI CSS Animations

Offset Outline Text

Hollow letters float over a solid copy that slides to each corner in turn, as if the light moved around them. The copy is a hard text-shadow, so a transparent fill still casts it.

Also known as: outline text with shadow css, retro offset text, hollow text shadow.

OFFSET

HTML

<div class="txt-offset-outline-text">OFFSET</div>

CSS

.txt-offset-outline-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.6);
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-weight: 900;
  line-height: 1.2;
  display: inline-block;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 0.03em currentColor;
  text-shadow: 0.08em 0.08em 0 var(--c);
  animation: txt-offset-outline-text-orbit 5s cubic-bezier(0.7, 0, 0.3, 1) infinite;}
@keyframes txt-offset-outline-text-orbit {
  0%, 20%, 100% { text-shadow: 0.08em 0.08em 0 var(--c); }
  25%, 45%      { text-shadow: -0.08em 0.08em 0 var(--c); }
  50%, 70%      { text-shadow: -0.08em -0.08em 0 var(--c); }
  75%, 95%      { text-shadow: 0.08em -0.08em 0 var(--c); }
}

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