AI CSS Animations

Stacked Outline Text

Four outlined copies stack into a 3D extrusion and a fill runs back through them layer by layer, then drains the same way. Grid-stacked spans, each offset and delayed by its --i.

Also known as: layered outline text css, 3d outline text, repeated outline text.

STACK

HTML

<div class="txt-stacked-outline-text"><span style="--i: 0">STACK</span><span style="--i: 1" aria-hidden="true">STACK</span><span style="--i: 2" aria-hidden="true">STACK</span><span style="--i: 3" aria-hidden="true">STACK</span></div>

CSS

.txt-stacked-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-grid;
  transform: translate(-0.09em, -0.09em);}
.txt-stacked-outline-text > span {
  grid-area: 1 / 1;
  z-index: calc(4 - var(--i));
  color: transparent;
  -webkit-text-stroke: 0.025em var(--c);
  transform: translate(calc(var(--i) * 0.06em), calc(var(--i) * 0.06em));
  animation: txt-stacked-outline-text-fill 3s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  animation-delay: calc(var(--i) * 0.14s);
}
@keyframes txt-stacked-outline-text-fill {
  0%, 12%, 100% { color: transparent; }
  34%, 62%      { color: var(--c); }
}

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