AI CSS Animations

Double Underline Link Hover

A plain underlined link whose line splits in two on hover: a copy drops below with a springy overshoot and a softer tint. Two pseudo-elements stacked on the same spot at rest.

Also known as: split underline hover, two line underline css, double line link animation.

HTML

<a class="hfx-link-double-underline" href="#">Press and media</a>

CSS

.hfx-link-double-underline {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  display: inline-block;
  color: var(--c);
  font: 600 calc(var(--hfx-size, 16px) * 1.25)/1.3 system-ui, sans-serif;
  text-decoration: none;
  color: inherit;
  padding-bottom: 0.45em;
  transition: color 0.3s ease;}
.hfx-link-double-underline::before,
.hfx-link-double-underline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.3em;
  height: 0.09em;
  border-radius: 1em;
  background: var(--c);
}
.hfx-link-double-underline::after {
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.hfx-link-double-underline:is(:hover, :focus-visible) { color: var(--c); }
.hfx-link-double-underline:is(:hover, :focus-visible)::after {
  transform: translateY(0.24em);
  opacity: 0.5;
}

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

Underline Grow Link
Underline from Center Link
Highlighter Link
Slide Up Text Link