Weekend in Lisbon
Three days of tiles, tarts and trams.
The card sinks into a slot in the page on hover, and the slot's four inner walls come into view around it. The walls are real planes behind the card, so the depth holds up at any size.
Also known as: sink into page hover, recessed card css, press into slot.
<div class="hfx-push-in-card">
<span class="hfx-push-in-card-wall hfx-push-in-card-top"></span>
<span class="hfx-push-in-card-wall hfx-push-in-card-bottom"></span>
<span class="hfx-push-in-card-wall hfx-push-in-card-left"></span>
<span class="hfx-push-in-card-wall hfx-push-in-card-right"></span>
<div class="hfx-push-in-card-tile">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 16V4M7 9l5-5 5 5M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>
<strong>Drop files here</strong>
<small>PNG, JPG or PDF up to 10 MB</small>
</div>
</div>.hfx-push-in-card {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
width: 14em;
height: 8em;
border: 0.45em solid color-mix(in srgb, var(--c) 14%, #fff);
border-radius: 1em;
perspective: 14em;
transform-style: preserve-3d;
font-family: system-ui, sans-serif;
}
.hfx-push-in-card-wall {
position: absolute;
}
.hfx-push-in-card-top,
.hfx-push-in-card-bottom {
left: 0;
right: 0;
height: 1.8em;
}
.hfx-push-in-card-left,
.hfx-push-in-card-right {
top: 0;
bottom: 0;
width: 1.8em;
}
.hfx-push-in-card-top {
top: 0;
background: linear-gradient(color-mix(in srgb, var(--c) 40%, #111827), color-mix(in srgb, var(--c) 25%, #6b7280));
transform-origin: 50% 0;
transform: rotateX(-90deg);
}
.hfx-push-in-card-bottom {
bottom: 0;
background: linear-gradient(color-mix(in srgb, var(--c) 15%, #e5e7eb), color-mix(in srgb, var(--c) 8%, #fff));
transform-origin: 50% 100%;
transform: rotateX(90deg);
}
.hfx-push-in-card-left {
left: 0;
background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, #4b5563), color-mix(in srgb, var(--c) 20%, #9ca3af));
transform-origin: 0 50%;
transform: rotateY(90deg);
}
.hfx-push-in-card-right {
right: 0;
background: linear-gradient(90deg, color-mix(in srgb, var(--c) 20%, #9ca3af), color-mix(in srgb, var(--c) 30%, #4b5563));
transform-origin: 100% 50%;
transform: rotateY(-90deg);
}
.hfx-push-in-card-tile {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.2em;
border-radius: 0.55em;
background: #fff;
color: #111827;
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 20%, transparent);
transition: transform 0.35s cubic-bezier(0.3, 1.35, 0.5, 1);
}
.hfx-push-in-card-tile svg {
width: 1.6em;
height: 1.6em;
margin-bottom: 0.2em;
color: var(--c);
}
.hfx-push-in-card-tile strong {
font-size: 0.95em;
}
.hfx-push-in-card-tile small {
font-size: 0.7em;
color: #6b7280;
}
.hfx-push-in-card:hover .hfx-push-in-card-tile {
transform: translateZ(-1.8em);
}
@media (prefers-reduced-motion: reduce) {
.hfx-push-in-card, .hfx-push-in-card *, .hfx-push-in-card::before, .hfx-push-in-card::after, .hfx-push-in-card *::before, .hfx-push-in-card *::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.