AI CSS Animations

Strike Through Link

A line draws through the middle of the text on hover while the text fades. Good for 'compare plans' style toggles and nav items that mean 'not this one'.

Also known as: line through hover, crossed out link.

HTML

<a class="hfx-link-strike" href="#">Old pricing</a>

CSS

.hfx-link-strike {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: inline-block;
  color: var(--c);
  font: 600 1em system-ui, sans-serif;
  text-decoration: none;
  color: inherit;
  transition: color 0.3s ease;}
.hfx-link-strike::after {
  content: "";
  position: absolute;
  left: 0;
  top: 55%;
  width: 100%;
  height: 2px;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.hfx-link-strike:hover { color: #9ca3af; }
.hfx-link-strike:hover::after { transform: scaleX(1); }

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