AI CSS Animations

Shutter Blinds Image Hover

Five colored slats sweep across the photo one after another, alternating sides like closing blinds, then a caption lands on top. The stagger is one transition-delay per slat.

Also known as: venetian blinds hover, staggered stripes overlay, blinds reveal image.

HTML

<figure class="hfx-image-shutter-blinds" role="img" aria-label="Mountains at dusk">
  <span class="hfx-image-shutter-blinds-slat" style="--i: 0"></span>
  <span class="hfx-image-shutter-blinds-slat" style="--i: 1"></span>
  <span class="hfx-image-shutter-blinds-slat" style="--i: 2"></span>
  <span class="hfx-image-shutter-blinds-slat" style="--i: 3"></span>
  <span class="hfx-image-shutter-blinds-slat" style="--i: 4"></span>
  <figcaption>Alpine evenings<small>24 photos</small></figcaption>
</figure>

CSS

.hfx-image-shutter-blinds {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 15em;
  height: 9.5em;
  margin: 0;
  border-radius: 0.75em;
  overflow: hidden;
  background:
    radial-gradient(70% 40% at 16% 110%, color-mix(in srgb, var(--c) 18%, #0b0a1f) 99%, transparent),
    radial-gradient(66% 38% at 88% 108%, color-mix(in srgb, var(--c) 24%, #0b0a1f) 99%, transparent),
    conic-gradient(from 128deg at 68% 44%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 103.6deg, transparent 104deg),
    conic-gradient(from 119deg at 90% 52%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 121.6deg, transparent 122deg),
    conic-gradient(from 123deg at 24% 40%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 113.6deg, transparent 114deg),
    conic-gradient(from 125deg at 46% 54%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 109.6deg, transparent 110deg),
    radial-gradient(circle at 38% 58%, #fef3c7 0 1em, rgb(254 215 170 / 0.55) 1.1em, transparent 4.2em),
    linear-gradient(color-mix(in srgb, var(--c) 58%, #1e1b4b), color-mix(in srgb, var(--c) 34%, #f472b6) 52%, color-mix(in srgb, var(--c) 12%, #fdba74) 76%);
  color: #fff;
  font-family: system-ui, sans-serif;
}
.hfx-image-shutter-blinds-slat {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--i) * 20%);
  height: calc(20% + 1px);
  background: color-mix(in srgb, var(--c) 82%, #0f172a);
  opacity: 0.94;
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1) calc(var(--i) * 0.05s);
}
.hfx-image-shutter-blinds-slat:nth-child(even) {
  transform-origin: 100% 50%;
}
.hfx-image-shutter-blinds figcaption {
  position: relative;
  padding: 0;
  color: inherit;
  font-family: inherit;
  display: grid;
  gap: 0.25em;
  text-align: center;
  font-weight: 700;
  font-size: 1.1em;
  opacity: 0;
  transform: translateY(0.4em);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.hfx-image-shutter-blinds small {
  font-weight: 500;
  font-size: 0.7em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}
.hfx-image-shutter-blinds:hover .hfx-image-shutter-blinds-slat {
  transform: scaleX(1);
}
.hfx-image-shutter-blinds:hover figcaption {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s ease 0.4s, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.4s;
}

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