AI CSS Animations

Page Curl Image Hover

The bottom corner of the photo is lifted a little at rest and peels back on hover to show the next photo underneath. A clip-path cuts the corner while a shaded triangle plays the folded flap.

Also known as: peel corner hover, folded corner css, turn page effect.

HTML

<a href="#" class="hfx-image-page-curl" aria-label="Next photo">
  <span class="hfx-image-page-curl-photo"></span>
</a>

CSS

.hfx-image-page-curl {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: block;
  width: 15em;
  height: 9.5em;
}
.hfx-image-page-curl::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 0.75em;
  background:
    radial-gradient(72% 42% at 22% 110%, color-mix(in srgb, var(--c) 10%, #020617) 99%, transparent),
    radial-gradient(64% 36% at 86% 107%, color-mix(in srgb, var(--c) 14%, #020617) 99%, transparent),
    conic-gradient(from 129deg at 70% 42%, transparent 0, color-mix(in srgb, var(--c) 22%, #0b1026) 0.4deg 101.6deg, transparent 102deg),
    conic-gradient(from 118deg at 92% 54%, transparent 0, color-mix(in srgb, var(--c) 22%, #0b1026) 0.4deg 123.6deg, transparent 124deg),
    conic-gradient(from 124deg at 28% 38%, transparent 0, color-mix(in srgb, var(--c) 36%, #111a3a) 0.4deg 111.6deg, transparent 112deg),
    conic-gradient(from 126deg at 50% 52%, transparent 0, color-mix(in srgb, var(--c) 36%, #111a3a) 0.4deg 107.6deg, transparent 108deg),
    radial-gradient(circle at 12% 18%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 24% 30%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 38% 12%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 46% 26%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 62% 16%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 88% 22%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 84% 40%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 8% 42%, #fff 0 0.05em, transparent 0.09em),
    radial-gradient(circle at 76% 24%, #f8fafc 0 0.65em, rgb(248 250 252 / 0.3) 0.75em, transparent 2.6em),
    linear-gradient(color-mix(in srgb, var(--c) 20%, #020617), color-mix(in srgb, var(--c) 52%, #1e1b4b) 82%);
}
.hfx-image-page-curl-photo {
  position: absolute;
  inset: 0;
  border-radius: 0.75em;
  background:
    radial-gradient(74% 44% at 20% 110%, color-mix(in srgb, var(--c) 42%, #0f172a) 99%, transparent),
    radial-gradient(62% 36% at 90% 107%, color-mix(in srgb, var(--c) 56%, #0f172a) 99%, transparent),
    conic-gradient(from 130deg at 72% 40%, transparent 0, color-mix(in srgb, var(--c) 80%, #1e293b) 0.4deg 99.6deg, transparent 100deg),
    conic-gradient(from 118deg at 94% 55%, transparent 0, color-mix(in srgb, var(--c) 80%, #1e293b) 0.4deg 123.6deg, transparent 124deg),
    conic-gradient(from 124deg at 30% 36%, transparent 0, color-mix(in srgb, var(--c) 48%, #fff) 0.4deg 111.6deg, transparent 112deg),
    conic-gradient(from 126deg at 52% 50%, transparent 0, color-mix(in srgb, var(--c) 48%, #fff) 0.4deg 107.6deg, transparent 108deg),
    radial-gradient(circle at 55% 27%, #fff 0 0.85em, rgb(255 255 255 / 0.45) 0.95em, transparent 3.2em),
    linear-gradient(color-mix(in srgb, var(--c) 64%, #fff), color-mix(in srgb, var(--c) 12%, #fff7ed) 72%);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 1em), calc(100% - 1em) 100%, 0 100%);
  transition: clip-path 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.hfx-image-page-curl::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 4em;
  height: 4em;
  background: linear-gradient(135deg, #f8fafc 10%, #e2e8f0 34%, #94a3b8 49.5%, transparent 50%);
  filter: drop-shadow(-0.15em -0.15em 0.25em rgb(2 6 23 / 0.35));
  transform: scale(0.25);
  transform-origin: 100% 100%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.hfx-image-page-curl:is(:hover, :focus-visible) .hfx-image-page-curl-photo {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 4em), calc(100% - 4em) 100%, 0 100%);
}
.hfx-image-page-curl:is(:hover, :focus-visible)::after {
  transform: none;
}

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