Weekend in Lisbon
Three days of tiles, tarts and trams.
At rest the photo is dark except for a soft spotlight in the middle; hover and the light spreads to the edges. The vignette is one radial gradient that scales up, so only a transform animates.
Also known as: vignette hover effect, flashlight reveal image, vignette fade on hover.
<div class="hfx-image-spotlight" role="img" aria-label="Mountains at dusk"></div>
.hfx-image-spotlight {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
width: 15em;
height: 9.5em;
border-radius: 0.75em;
overflow: hidden;
background:
radial-gradient(70% 40% at 16% 110%, color-mix(in srgb, var(--c) 18%, #0b0a1f) 99%, transparent),
radial-gradient(66% 38% at 88% 108%, color-mix(in srgb, var(--c) 24%, #0b0a1f) 99%, transparent),
conic-gradient(from 128deg at 68% 44%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 103.6deg, transparent 104deg),
conic-gradient(from 119deg at 90% 52%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 121.6deg, transparent 122deg),
conic-gradient(from 123deg at 24% 40%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 113.6deg, transparent 114deg),
conic-gradient(from 125deg at 46% 54%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 109.6deg, transparent 110deg),
radial-gradient(circle at 38% 58%, #fef3c7 0 1em, rgb(254 215 170 / 0.55) 1.1em, transparent 4.2em),
linear-gradient(color-mix(in srgb, var(--c) 58%, #1e1b4b), color-mix(in srgb, var(--c) 34%, #f472b6) 52%, color-mix(in srgb, var(--c) 12%, #fdba74) 76%);
}
.hfx-image-spotlight::after {
content: "";
position: absolute;
inset: -60%;
background: radial-gradient(circle at 50% 50%, transparent 2.4em, rgb(2 6 23 / 0.86) 4.8em);
transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.hfx-image-spotlight:hover::after {
transform: scale(4.5);
}
@media (prefers-reduced-motion: reduce) {
.hfx-image-spotlight, .hfx-image-spotlight *, .hfx-image-spotlight::before, .hfx-image-spotlight::after, .hfx-image-spotlight *::before, .hfx-image-spotlight *::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.