Weekend in Lisbon
Three days of tiles, tarts and trams.
The card rests tipped back as if lying on a desk, and stands up to face you on hover with a springy overshoot. It hinges on its bottom edge, and a shade on the card lifts as it rises.
Also known as: card rises on hover, lay flat card hover, rotateX stand up card.
Three days of tiles, tarts and trams.
<div class="hfx-stand-up-card">
<article class="hfx-stand-up-card-card">
<div class="hfx-stand-up-card-image"></div>
<div class="hfx-stand-up-card-body">
<h3>Weekend in Lisbon</h3>
<p>Three days of tiles, tarts and trams.</p>
</div>
</article>
</div>.hfx-stand-up-card {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
perspective: 40em;
font-family: system-ui, sans-serif;
}
.hfx-stand-up-card-card {
position: relative;
width: 13em;
overflow: hidden;
border: 1px solid color-mix(in srgb, #000 10%, transparent);
border-radius: 0.75em;
background: #fff;
color: #1f2937;
transform-origin: 50% 100%;
transform: rotateX(48deg);
transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.6s ease;
}
.hfx-stand-up-card-card::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(color-mix(in srgb, #000 18%, transparent), transparent 70%);
transition: opacity 0.6s ease;
}
.hfx-stand-up-card-image {
height: 5em;
background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #fff), var(--c));
}
.hfx-stand-up-card-body {
padding: 0.8em 1em 1em;
}
.hfx-stand-up-card h3 {
margin: 0 0 0.2em;
font-size: 1.05em;
}
.hfx-stand-up-card p {
margin: 0;
font-size: 0.85em;
color: #6b7280;
}
.hfx-stand-up-card:hover .hfx-stand-up-card-card {
transform: rotateX(0deg);
box-shadow: 0 1em 1.6em color-mix(in srgb, #000 15%, transparent);
}
.hfx-stand-up-card:hover .hfx-stand-up-card-card::after {
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
.hfx-stand-up-card, .hfx-stand-up-card *, .hfx-stand-up-card::before, .hfx-stand-up-card::after, .hfx-stand-up-card *::before, .hfx-stand-up-card *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<div class="group [perspective:40em]">
<article class="w-52 origin-bottom overflow-hidden rounded-xl border bg-white transition duration-500 ease-[cubic-bezier(.34,1.56,.64,1)] [transform:rotateX(48deg)] group-hover:shadow-xl group-hover:[transform:rotateX(0deg)]">
<div class="h-20 bg-gradient-to-br from-blue-300 to-blue-500"></div>
<div class="p-4">
<h3 class="font-semibold">Weekend in Lisbon</h3>
<p class="text-sm text-gray-500">Three days of tiles, tarts and trams.</p>
</div>
</article>
</div>--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.