AI CSS Animations

Film Strip Border

A frame of film between two rows of sprocket holes that roll past as if it were running through a projector. Each row is one wide gradient strip, slid by exactly one hole per loop with transform.

Also known as: film strip css, filmstrip border animation, movie film border.

Scene 24

HTML

<div class="bdr-film-strip-border">
  <span class="bdr-film-strip-border-holes"></span>
  <span class="bdr-film-strip-border-holes"></span>
  <span class="bdr-film-strip-border-frame">Scene 24</span>
</div>

CSS

.bdr-film-strip-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;
  overflow: hidden;
  border-radius: 0.3em;
  background: color-mix(in srgb, var(--c) 8%, #0e0e11);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 12%, transparent);
}
.bdr-film-strip-border-holes {
  position: absolute;
  top: 0.4em;
  left: 0;
  width: calc(100% + 1.2em);
  height: 0.6em;
  background: linear-gradient(90deg, #e7e5e4 0 0.62em, transparent 0) 0.3em 0 / 1.2em 100% repeat-x;
  animation: bdr-film-strip-border-roll 0.5s linear infinite;
}
.bdr-film-strip-border-holes + .bdr-film-strip-border-holes {
  top: auto;
  bottom: 0.4em;
}
.bdr-film-strip-border-frame {
  position: absolute;
  inset: 1.35em 0.7em;
  display: grid;
  place-items: center;
  border-radius: 0.2em;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 70%, #000));
  color: #fff;
  letter-spacing: 0.04em;
  animation: bdr-film-strip-border-flicker 0.3s steps(2) infinite;
}
@keyframes bdr-film-strip-border-roll {
  to { transform: translateX(-1.2em); }
}
@keyframes bdr-film-strip-border-flicker {
  50% { opacity: 0.93; }
}

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