AI CSS Animations

Live Scoreboard Score Change

A broadcast score bug: the home score rolls from 102 to 105 with a +3 pop and a sweep of team color, then the away side scores two. Digit strips, one shared timeline, own dark panel.

Also known as: scoreboard animation css, score change animation, sports score bug css, number animation css.

HTML

<div class="txt-live-scoreboard" aria-label="Score: SEA 105, ATL 98, fourth quarter">
  <span class="txt-live-scoreboard-side txt-live-scoreboard-home" aria-hidden="true">
    <b>SEA</b>
    <span class="txt-live-scoreboard-score">10<span class="txt-live-scoreboard-col"><span class="txt-live-scoreboard-h1">2345</span></span><i>+3</i></span>
  </span>
  <span class="txt-live-scoreboard-side txt-live-scoreboard-away" aria-hidden="true">
    <span class="txt-live-scoreboard-score">9<span class="txt-live-scoreboard-col"><span class="txt-live-scoreboard-a1">678</span></span><i>+2</i></span>
    <b>ATL</b>
  </span>
  <span class="txt-live-scoreboard-clock" aria-hidden="true"><b>Q4</b>2:14</span>
</div>

CSS

.txt-live-scoreboard {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 0.85);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  align-items: stretch;
  padding: 0.2em;
  border-radius: 0.5em;
  color: #f5f5f5;
  background: linear-gradient(#1c1f26, #111318);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07), 0 0.5em 1.2em -0.6em rgb(0 0 0 / 0.5);
  font-variant-numeric: tabular-nums;
  --t: 8.4s;}
.txt-live-scoreboard-side {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.25em 0.55em;
  border-radius: 0.32em;
  overflow: hidden;
}
.txt-live-scoreboard-side b {
  font-size: 0.55em;
  font-weight: 750;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.txt-live-scoreboard-home { --team: var(--c); box-shadow: inset 0.16em 0 0 var(--team); }
.txt-live-scoreboard-away { --team: #e5484d; box-shadow: inset -0.16em 0 0 var(--team); }
/* the color sweep when a side scores */
.txt-live-scoreboard-side::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--team) 45%, transparent), transparent);
  transform: translateX(-110%);
  animation: txt-live-scoreboard-sweep var(--t) infinite;
}
.txt-live-scoreboard-away::after { animation-delay: 2.8s; }
.txt-live-scoreboard-score {
  position: relative;
  display: inline-flex;
  font-size: 1.15em;
  font-weight: 750;
  line-height: 1.1em;
}
.txt-live-scoreboard-col {
  display: inline-block;
  height: 1.1em;
  overflow: hidden;
  line-height: 1.1em;
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}
.txt-live-scoreboard-col > span {
  display: block;
  width: 1ch;
  text-align: center;
  word-break: break-all;
}
.txt-live-scoreboard-h1 { animation: txt-live-scoreboard-h1 var(--t) infinite; }
.txt-live-scoreboard-a1 { animation: txt-live-scoreboard-a1 var(--t) infinite; }
.txt-live-scoreboard-score i {
  position: absolute;
  right: -0.2em;
  top: -0.15em;
  font-size: 0.42em;
  font-style: normal;
  font-weight: 800;
  color: var(--team);
  opacity: 0;
  animation: txt-live-scoreboard-pop var(--t) infinite;
}
.txt-live-scoreboard-away .txt-live-scoreboard-score i { right: auto; left: -0.2em; animation-delay: 2.8s; }
.txt-live-scoreboard-clock {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0.55em;
  margin-left: 0.15em;
  border-left: 1px solid rgb(255 255 255 / 0.1);
  font-size: 0.5em;
  font-weight: 600;
  line-height: 1.25;
  color: rgb(255 255 255 / 0.65);
}
.txt-live-scoreboard-clock b {
  font-weight: 800;
  color: #fff;
}
.txt-live-scoreboard-score { animation: txt-live-scoreboard-reset var(--t) infinite; }
@keyframes txt-live-scoreboard-h1 {
  0% { transform: translateY(0); }
  19.05% { transform: translateY(0); animation-timing-function: cubic-bezier(0.34, 1.4, 0.64, 1); }
  27.98% { transform: translateY(-3.3em); }
  96.43% { transform: translateY(-3.3em); }
  96.67%, 100% { transform: translateY(0); }
}
@keyframes txt-live-scoreboard-a1 {
  0% { transform: translateY(0); }
  52.38% { transform: translateY(0); animation-timing-function: cubic-bezier(0.34, 1.4, 0.64, 1); }
  61.31% { transform: translateY(-2.2em); }
  96.43% { transform: translateY(-2.2em); }
  96.67%, 100% { transform: translateY(0); }
}
@keyframes txt-live-scoreboard-sweep {
  0%, 18% { transform: translateX(-110%); }
  30%, 100% { transform: translateX(110%); }
}
@keyframes txt-live-scoreboard-pop {
  0%, 18% { opacity: 0; transform: translateY(0.4em) scale(0.6); }
  23% { opacity: 1; transform: translateY(-0.5em) scale(1.1); animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
  34% { opacity: 1; transform: translateY(-0.7em); }
  40%, 100% { opacity: 0; transform: translateY(-0.9em); }
}
@keyframes txt-live-scoreboard-reset {
  0%, 92% { opacity: 1; filter: none; }
  95%, 97.5% { opacity: 0; filter: blur(0.1em); }
  100% { opacity: 1; filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .txt-live-scoreboard, .txt-live-scoreboard *, .txt-live-scoreboard *::before, .txt-live-scoreboard *::after { animation: none !important; }
}

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