AI CSS Animations

Fire Border

Flame colors climb both sides of a dark box while a hot, flickering glow leaks out and upward. A vertical gradient loops its position upward, and a blurred copy flickers in opacity behind it.

Also known as: fire border animation css, flame border css, burning border effect.

On fire

HTML

<div class="bdr-fire-border">On fire</div>

CSS

.bdr-fire-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;
  --ember: color-mix(in srgb, var(--c) 8%, #140806);
  --fire: linear-gradient(0deg, #7f1d1d, #dc2626, #f97316, #fbbf24, #fef3c7, #fbbf24, #f97316, #dc2626, #7f1d1d) 0 0 / 100% 5em;
  isolation: isolate;
  color: #fde68a;
  letter-spacing: 0.04em;
}
.bdr-fire-border::before,
.bdr-fire-border::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
}
.bdr-fire-border::before {
  inset: 0.1em 0.15em 0.5em;
  background: var(--fire);
  filter: blur(0.55em);
  transform: translateY(-0.2em);
  animation:
    bdr-fire-border-rise 1.6s linear infinite,
    bdr-fire-border-flicker 1.9s linear infinite;
}
.bdr-fire-border::after {
  inset: 0;
  border: 0.18em solid transparent;
  background: linear-gradient(var(--ember), var(--ember)) padding-box, var(--fire) border-box;
  animation: bdr-fire-border-rise 1.6s linear infinite;
}
@keyframes bdr-fire-border-rise {
  to { background-position: 0 -5em; }
}
@keyframes bdr-fire-border-flicker {
  0%, 100% { opacity: 0.8; }
  12%      { opacity: 0.55; }
  27%      { opacity: 0.95; }
  41%      { opacity: 0.6; }
  58%      { opacity: 1; }
  73%      { opacity: 0.65; }
  88%      { opacity: 0.9; }
}

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