AI CSS Animations

Zipper Letters Text Animation

Odd letters drop in from above and even letters rise from below, closing left to right like a zipper. The direction comes from an nth-child custom property that one keyframe reads.

Also known as: alternating letters animation, letters from top and bottom, zip text effect.

Zip it up

HTML

<div class="txt-zipper-letters" aria-label="Zip it up"><span style="--i: 0">Z</span><span style="--i: 1">i</span><span style="--i: 2">p</span><span style="--i: 3">&nbsp;</span><span style="--i: 4">i</span><span style="--i: 5">t</span><span style="--i: 6">&nbsp;</span><span style="--i: 7">u</span><span style="--i: 8">p</span></div>

CSS

.txt-zipper-letters {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--c);
  white-space: nowrap;}
.txt-zipper-letters span {
  --from: -0.9em;
  display: inline-block;
  animation: txt-zipper-letters-close 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.15) calc(0.1s + var(--i) * 45ms) both;
}
.txt-zipper-letters span:nth-child(even) {
  --from: 0.9em;
}
@keyframes txt-zipper-letters-close {
  0%   { opacity: 0; transform: translateY(var(--from)) scaleY(1.2); }
  35%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scaleY(1); }
}

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