Weekend in Lisbon
Three days of tiles, tarts and trams.
A small stack of photo prints that fans out on hover, the back two swinging to either side on a springy curve. One custom property per card drives both its resting tilt and its fan angle.
Also known as: card stack hover, fan out cards css, photo stack hover.
<div class="hfx-card-stack-fan">
<div class="hfx-card-stack-fan-card" style="--i: -1"><div class="hfx-card-stack-fan-photo"></div></div>
<div class="hfx-card-stack-fan-card" style="--i: 1"><div class="hfx-card-stack-fan-photo"></div></div>
<figure class="hfx-card-stack-fan-card hfx-card-stack-fan-top" style="--i: 0">
<div class="hfx-card-stack-fan-photo"></div>
<figcaption>Porto, June</figcaption>
</figure>
</div>.hfx-card-stack-fan {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
width: 7.2em;
height: 8.8em;
font-family: system-ui, sans-serif;
}
.hfx-card-stack-fan-card {
position: absolute;
inset: 0;
box-sizing: border-box;
margin: 0;
padding: 0.45em 0.45em 0;
border-radius: 0.35em;
background: #fff;
box-shadow: 0 0 0 1px color-mix(in srgb, #000 8%, transparent), 0 0.4em 0.9em -0.4em color-mix(in srgb, #000 35%, transparent);
transform-origin: 50% 115%;
transform: rotate(calc(var(--i) * 5deg));
transition: transform 0.5s cubic-bezier(0.34, 1.45, 0.64, 1);
}
.hfx-card-stack-fan:hover .hfx-card-stack-fan-card {
transform: translateX(calc(var(--i) * 4em)) rotate(calc(var(--i) * 13deg));
}
.hfx-card-stack-fan:hover .hfx-card-stack-fan-top {
transform: translateY(-0.35em) scale(1.04);
}
.hfx-card-stack-fan-photo {
height: 6.3em;
border-radius: 0.15em;
background: radial-gradient(120% 70% at 18% 100%, color-mix(in srgb, var(--c) 75%, #000) 0 50%, transparent 51%),
radial-gradient(140% 80% at 88% 100%, color-mix(in srgb, var(--c) 50%, #fff) 0 50%, transparent 51%),
radial-gradient(circle at 70% 38%, #fff7d6 0 12%, transparent 13%),
linear-gradient(to bottom, color-mix(in srgb, var(--c) 30%, #fff), color-mix(in srgb, var(--c) 55%, #fff));
}
.hfx-card-stack-fan-card:not(.hfx-card-stack-fan-top) .hfx-card-stack-fan-photo {
filter: hue-rotate(calc(var(--i) * 55deg)) saturate(0.85);
}
.hfx-card-stack-fan figcaption {
padding: 0.55em 0 0;
font-family: Georgia, serif;
font-size: 0.7em;
font-style: italic;
text-align: center;
color: #4b5563;
}
@media (prefers-reduced-motion: reduce) {
.hfx-card-stack-fan, .hfx-card-stack-fan *, .hfx-card-stack-fan::before, .hfx-card-stack-fan::after, .hfx-card-stack-fan *::before, .hfx-card-stack-fan *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.