Weekend in Lisbon
Three days of tiles, tarts and trams.
A caption panel slides up over the image on hover, the classic portfolio and gallery treatment. The panel is inside the image frame so it never changes the card's height.
Also known as: image overlay hover, slide up caption, portfolio hover.
<figure class="hfx-card-reveal">
<div class="hfx-card-reveal-image"></div>
<figcaption>
<strong>Alfama at dusk</strong>
<span>Lisbon, Portugal</span>
</figcaption>
</figure>.hfx-card-reveal {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
width: 15em;
border-radius: 0.75em;
overflow: hidden;
background: #fff;
border: 1px solid color-mix(in srgb, #000 10%, transparent);
color: #1f2937;
font-family: system-ui, sans-serif;
position: relative;
margin: 0;
aspect-ratio: 4 / 3;}
.hfx-card-reveal-image {
position: absolute;
inset: 0;
background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #fff), var(--c));
transition: transform 0.5s ease;
}
.hfx-card-reveal figcaption {
position: absolute;
inset: auto 0 0;
display: grid;
gap: 0.2em;
padding: 0.9em 1em;
background: color-mix(in srgb, #000 65%, transparent);
color: #fff;
transform: translateY(100%);
transition: transform 0.35s ease;
}
.hfx-card-reveal figcaption span {
font-size: 0.8em;
opacity: 0.8;
}
.hfx-card-reveal:hover figcaption { transform: translateY(0); }
.hfx-card-reveal:hover .hfx-card-reveal-image { transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) {
.hfx-card-reveal, .hfx-card-reveal *, .hfx-card-reveal::before, .hfx-card-reveal::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.