AI CSS Animations

Double Underline Animation

The bookkeeper's double rule under a grand total: one line draws left to right, the second comes back right to left beneath it. Two pseudo-elements, one keyframe, opposite transform origins.

Also known as: double underline css, accounting total underline, two line underline text.

Total $1,240.00

HTML

<div class="txt-double-underline-text">Total <span class="txt-double-underline-text-sum">$1,240.00</span></div>

CSS

.txt-double-underline-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;}
.txt-double-underline-text-sum {
  position: relative;
  display: inline-block;
  margin-left: 0.2em;
  color: var(--c);
}
.txt-double-underline-text-sum::before,
.txt-double-underline-text-sum::after {
  content: "";
  position: absolute;
  left: -0.04em;
  right: -0.04em;
  height: 0.06em;
  border-radius: 0.03em;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: 0 50%;
  animation: txt-double-underline-text-draw 0.5s cubic-bezier(0.65, 0, 0.35, 1) 0.3s forwards;
}
.txt-double-underline-text-sum::before { bottom: 0; }
.txt-double-underline-text-sum::after {
  bottom: -0.14em;
  transform-origin: 100% 50%;
  animation-delay: 0.7s;
}
@keyframes txt-double-underline-text-draw {
  to { transform: scaleX(1); }
}

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