AI CSS Animations

Expanding Acronym Text Hover

A three-letter acronym unfolds into its full words on hover, the missing letters sliding out from behind each initial. Each tail is a grid track that transitions from 0fr to 1fr.

Also known as: expand text on hover, abbreviation reveal, acronym unfold animation.

Do  It  Yourself

HTML

<div class="hfx-text-acronym-expand" aria-label="Do it yourself">
  <span>D<span class="hfx-text-acronym-expand-tail"><span>o&nbsp;</span></span></span>
  <span>I<span class="hfx-text-acronym-expand-tail"><span>t&nbsp;</span></span></span>
  <span>Y<span class="hfx-text-acronym-expand-tail"><span>ourself</span></span></span>
</div>

CSS

.hfx-text-acronym-expand {
  --c: var(--hfx-color, #3b82f6);
  font-size: calc(var(--hfx-size, 16px) * 2.2);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.15;
  cursor: default;
  display: inline-flex;
  font-weight: 900;
  letter-spacing: 0.02em;}
.hfx-text-acronym-expand > span {
  display: inline-flex;
  transition: color 0.4s ease;
}
.hfx-text-acronym-expand-tail {
  display: grid;
  grid-template-columns: 0fr;
  font-weight: 500;
  color: var(--c);
  opacity: 0;
  transition: grid-template-columns 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}
.hfx-text-acronym-expand-tail > span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.hfx-text-acronym-expand > span:nth-child(2) .hfx-text-acronym-expand-tail { transition-delay: 0.05s; }
.hfx-text-acronym-expand > span:nth-child(3) .hfx-text-acronym-expand-tail { transition-delay: 0.1s; }
.hfx-text-acronym-expand:hover .hfx-text-acronym-expand-tail {
  grid-template-columns: 1fr;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-text-acronym-expand, .hfx-text-acronym-expand *, .hfx-text-acronym-expand::before, .hfx-text-acronym-expand::after, .hfx-text-acronym-expand *::before, .hfx-text-acronym-expand *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • 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 hover effects