AI CSS Animations

Neon Sign Border

Two neon tubes on a dark sign stutter on one after the other, hold, blink twice together and go dark. The unlit glass stays faintly visible. Each tube is one element, and only opacity animates.

Also known as: neon sign border css, flickering neon border, double neon border.

Arcade

HTML

<div class="bdr-neon-sign-border">
  <span class="bdr-neon-sign-border-outer"></span>
  <span class="bdr-neon-sign-border-inner"></span>
  <span class="bdr-neon-sign-border-text">Arcade</span>
</div>

CSS

.bdr-neon-sign-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;
  --lit: color-mix(in srgb, var(--c) 35%, #fff);
  background: color-mix(in srgb, var(--c) 6%, #09090d);
  color: var(--lit);
}
.bdr-neon-sign-border-outer,
.bdr-neon-sign-border-inner {
  position: absolute;
  border: 0.14em solid var(--lit);
  box-shadow:
    0 0 0.15em var(--c),
    0 0 0.6em var(--c),
    inset 0 0 0.15em var(--c),
    inset 0 0 0.6em color-mix(in srgb, var(--c) 50%, transparent);
  animation: 4.5s linear infinite;
}
.bdr-neon-sign-border-outer {
  inset: 0.5em;
  border-radius: 0.65em;
  animation-name: bdr-neon-sign-border-outer;
}
.bdr-neon-sign-border-inner {
  inset: 1.05em;
  border-width: 0.1em;
  border-radius: 0.35em;
  filter: hue-rotate(110deg);
  animation-name: bdr-neon-sign-border-inner;
}
.bdr-neon-sign-border-text {
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 0 0.12em var(--c), 0 0 0.45em var(--c);
  animation: bdr-neon-sign-border-outer 4.5s linear infinite;
}
@keyframes bdr-neon-sign-border-outer {
  0%, 6%, 94%, 100% { opacity: 0.14; }
  7%   { opacity: 1; }
  8%   { opacity: 0.3; }
  10%  { opacity: 1; }
  11%  { opacity: 0.5; }
  12%, 78% { opacity: 1; }
  79%, 81% { opacity: 0.14; }
  82%, 84% { opacity: 1; }
  85%, 87% { opacity: 0.14; }
  88%, 93% { opacity: 1; }
}
@keyframes bdr-neon-sign-border-inner {
  0%, 22%, 94%, 100% { opacity: 0.14; }
  23%  { opacity: 1; }
  24%  { opacity: 0.25; }
  26%  { opacity: 0.9; }
  27%, 78% { opacity: 1; }
  79%, 81% { opacity: 0.14; }
  82%, 84% { opacity: 1; }
  85%, 87% { opacity: 0.14; }
  88%, 93% { opacity: 1; }
}

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