Weekend in Lisbon
Three days of tiles, tarts and trams.
A photo standing on a glossy floor, with a faded mirror image under it. On hover the photo lifts and the reflection drops away and dims, the way a real one would. Uses a flipped copy and a mask.
Also known as: mirror reflection css, image reflection effect, glossy floor reflection.
<figure class="hfx-image-reflection" role="img" aria-label="Mountain range"> <div class="hfx-image-reflection-photo"></div> <div class="hfx-image-reflection-mirror"></div> </figure>
.hfx-image-reflection {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
display: grid;
gap: 0.2em;
width: 12em;
margin: 0;
}
.hfx-image-reflection-photo,
.hfx-image-reflection-mirror {
border-radius: 0.6em;
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%);
background-size: 12em 7.5em;
transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease;
}
.hfx-image-reflection-photo {
height: 7.5em;
}
.hfx-image-reflection-mirror {
height: 3.6em;
background-position: 0 100%;
transform: scaleY(-1);
-webkit-mask-image: linear-gradient(to top, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0.15) 60%, transparent);
mask-image: linear-gradient(to top, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0.15) 60%, transparent);
}
.hfx-image-reflection:hover .hfx-image-reflection-photo {
transform: translateY(-0.45em);
}
.hfx-image-reflection:hover .hfx-image-reflection-mirror {
transform: translateY(0.45em) scaleY(-1);
opacity: 0.6;
}
@media (prefers-reduced-motion: reduce) {
.hfx-image-reflection, .hfx-image-reflection *, .hfx-image-reflection::before, .hfx-image-reflection::after, .hfx-image-reflection *::before, .hfx-image-reflection *::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.