AI CSS Animations

Pulse Hover Effect

While hovered, the button breathes in and out around its own size, a little bigger then a little smaller, once a second. It stops the moment the pointer leaves, so it never nags at rest.

Also known as: hvr-pulse, pulsing button on hover, hover.css pulse.

HTML

<button class="hfx-pulse"><span class="hfx-pulse-dot"></span>Watch live</button>

CSS

.hfx-pulse {
  --c: var(--hfx-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.6em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px) system-ui, sans-serif;
  cursor: pointer;
  border: 0;
  background: var(--c);
  color: #fff;
  border-radius: 2em;}
.hfx-pulse-dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0.2em rgb(255 255 255 / 0.3);
}
.hfx-pulse:is(:hover, :focus-visible) {
  animation: hfx-pulse-beat 1s linear infinite;
}
@keyframes hfx-pulse-beat {
  0%, 100% { transform: scale(1); animation-timing-function: ease-out; }
  25%      { transform: scale(1.09); animation-timing-function: ease-in-out; }
  75%      { transform: scale(0.95); animation-timing-function: ease-in; }
}

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