AI CSS Animations

Gradient Bottom Border

Only the bottom edge carries the border: a gradient bar that flows left to right under a panel, with a soft glow beneath. One background layer sized to the bottom strip loops its position.

Also known as: gradient border bottom css, animated border bottom css, gradient underline border.

Section heading

HTML

<div class="bdr-gradient-bottom-border">Section heading</div>

CSS

.bdr-gradient-bottom-border {
  --c: var(--bdr-color, #3b82f6);
  font-size: var(--bdr-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 15em;
  height: 8.5em;
  border-radius: 1em;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  --bar: linear-gradient(90deg, var(--c), color-mix(in oklch, var(--c), #ec4899 80%), color-mix(in oklch, var(--c), #f59e0b 75%), var(--c));
  border-radius: 0.8em 0.8em 0.25em 0.25em;
  background: var(--bar) 0 100% / 15em 0.22em repeat-x, color-mix(in srgb, var(--c) 8%, transparent);
  animation: bdr-gradient-bottom-border-flow 3s linear infinite;
}
.bdr-gradient-bottom-border::after {
  content: "";
  position: absolute;
  inset: auto 1em -0.25em;
  height: 0.35em;
  background: var(--bar) 0 0 / 15em 100% repeat-x;
  filter: blur(0.45em);
  opacity: 0.7;
  pointer-events: none;
  animation: bdr-gradient-bottom-border-flow 3s linear infinite;
}
@keyframes bdr-gradient-bottom-border-flow {
  from { background-position: -1em 100%, 0 0; }
  to   { background-position: 14em 100%, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bdr-gradient-bottom-border, .bdr-gradient-bottom-border *, .bdr-gradient-bottom-border::before, .bdr-gradient-bottom-border::after, .bdr-gradient-bottom-border *::before, .bdr-gradient-bottom-border *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --bdr-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --bdr-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 border animations