AI CSS Animations

Polaroid Image Hover

A tilted instant print with a handwritten caption that straightens, lifts and throws a longer shadow on hover, with a little overshoot. The faded film tone clears as it rises.

Also known as: polaroid photo hover, tilted photo frame, instant photo card.

Lake Bled, June

HTML

<figure class="hfx-image-polaroid">
  <div class="hfx-image-polaroid-photo" role="img" aria-label="Sunset over the sea"></div>
  <figcaption>Lake Bled, June</figcaption>
</figure>

CSS

.hfx-image-polaroid {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  width: 10.5em;
  margin: 0;
  padding: 0.6em 0.6em 0;
  border-radius: 0.2em;
  background: #fff;
  box-shadow: 0 0.2em 0.5em rgb(15 23 42 / 0.18), 0 0 0 1px rgb(15 23 42 / 0.06);
  transform: rotate(-5deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.45s ease;
}
.hfx-image-polaroid-photo {
  height: 7em;
  background:
    radial-gradient(9% 30% at 50% 74%, rgb(255 255 255 / 0.55), transparent),
    linear-gradient(transparent 62%, color-mix(in srgb, var(--c) 78%, #0f172a) 62%, color-mix(in srgb, var(--c) 62%, #0f172a) 74%, color-mix(in srgb, var(--c) 40%, #020617)),
    radial-gradient(34% 16% at 6% 63%, color-mix(in srgb, var(--c) 36%, #0f172a) 99%, transparent),
    radial-gradient(20% 9% at 92% 62%, color-mix(in srgb, var(--c) 48%, #1e293b) 99%, transparent),
    radial-gradient(circle at 50% 50%, #fffbeb 0 0.9em, rgb(254 243 199 / 0.5) 1em, transparent 3.6em),
    linear-gradient(color-mix(in srgb, var(--c) 56%, #fff), color-mix(in srgb, var(--c) 18%, #fed7aa) 62%);
  filter: sepia(0.35) saturate(0.85) brightness(1.05);
  transition: filter 0.45s ease;
}
.hfx-image-polaroid figcaption {
  padding: 0.5em 0 0.65em;
  color: #334155;
  font: italic 0.9em/1.2 "Bradley Hand", "Segoe Print", "Marker Felt", cursive;
  text-align: center;
}
.hfx-image-polaroid:hover {
  transform: translateY(-0.3em) rotate(2deg) scale(1.05);
  box-shadow: 0 1em 1.4em -0.5em rgb(15 23 42 / 0.4), 0 0 0 1px rgb(15 23 42 / 0.06);
}
.hfx-image-polaroid:hover .hfx-image-polaroid-photo {
  filter: none;
}

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