AI CSS Animations

Neon Sign Card Hover

A dark card with an unlit neon tube for a border and title. On hover the tube stutters on like a real sign, then holds a steady glow. One keyframe set drives both the tube and the lettering.

Also known as: neon card hover css, neon glow border card, flickering neon effect.

Open late

Cocktails and vinyl until 2 am, Thursday to Saturday.

HTML

<article class="hfx-card-neon-sign">
  <h3>Open late</h3>
  <p>Cocktails and vinyl until 2 am, Thursday to Saturday.</p>
</article>

CSS

.hfx-card-neon-sign {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  --hfx-card-neon-sign-lit: color-mix(in srgb, var(--c) 35%, #fff);
  position: relative;
  box-sizing: border-box;
  width: 14em;
  padding: 1.2em 1.3em 1.3em;
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: 0.9em;
  background: #0a0a10;
  color: color-mix(in srgb, #fff 55%, transparent);
  font-family: system-ui, sans-serif;
}
.hfx-card-neon-sign::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 0.12em solid var(--hfx-card-neon-sign-lit);
  border-radius: inherit;
  box-shadow: 0 0 0.4em var(--c), 0 0 1.2em color-mix(in srgb, var(--c) 60%, transparent), inset 0 0 0.5em color-mix(in srgb, var(--c) 45%, transparent);
  opacity: 0;
  pointer-events: none;
}
.hfx-card-neon-sign h3 {
  margin: 0 0 0.3em;
  font-size: 1.35em;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--c) 45%, transparent);
}
.hfx-card-neon-sign p {
  margin: 0;
  font-size: 0.8em;
  line-height: 1.45;
}
.hfx-card-neon-sign:hover::before { animation: hfx-card-neon-sign-flicker 0.9s linear both; }
.hfx-card-neon-sign:hover h3 {
  color: var(--hfx-card-neon-sign-lit);
  text-shadow: 0 0 0.2em var(--c), 0 0 0.6em var(--c);
  animation: hfx-card-neon-sign-flicker 0.9s linear both;
}
@keyframes hfx-card-neon-sign-flicker {
  0% { opacity: 0.2; }
  8% { opacity: 1; }
  12% { opacity: 0.25; }
  22% { opacity: 1; }
  26% { opacity: 0.4; }
  30% { opacity: 0.3; }
  38% { opacity: 1; }
  44% { opacity: 0.6; }
  52%, 100% { opacity: 1; }
}

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