Hover Lift
卡片上浮
The card moves upward and gains a deeper shadow when you hover or focus it.
Where to use it
Give clickable product cards, gallery tiles, and links a clear response. Use a small lift in a grid where whole cards are links. Apply it on keyboard focus as well so both input methods identify the active card.
Practical example
Place it on a recipe site's meal cards. Hovering or tabbing to the tomato soup card raises it and deepens its shadow, showing which recipe will open.
Also called
- Hover Elevation
AI prompt
Add Hover Lift to [target card]. On hover and keyboard focus, move the card up 4px and deepen its shadow over about 180ms. Keep the motion out of document flow and preserve the link and its visible focus style. For reduced motion, use the shadow change alone.
Example code
Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.
View HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hover Lift</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.lift {
display: grid;
grid-template-columns: 56px 1fr;
align-items: center;
gap: 13px;
width: min(100%, 224px);
padding: 10px;
text-align: start;
color: #221833;
background: #f3edff;
border: 1px solid #fff;
border-radius: 15px;
box-shadow: 0 7px 0 #3d325c;
font: inherit;
cursor: pointer;
transition: transform 230ms ease, box-shadow 230ms ease;
}
.lift:is(:focus-visible, [aria-pressed="true"]) {
transform: translateY(-9px);
box-shadow: 0 16px 0 #3d325c, 0 26px 28px #0b081c99;
}
@media (hover: hover) {
.lift:hover {
transform: translateY(-9px);
box-shadow: 0 16px 0 #3d325c, 0 26px 28px #0b081c99;
}
}
.lift-art {
display: grid;
place-items: center;
height: 52px;
border-radius: 8px;
background: #ccbfff;
}
.lift-art span {
width: 24px;
height: 29px;
border: 4px solid #43316d;
border-radius: 50%;
transform: rotate(34deg);
box-shadow: 5px -2px 0 #f1eaff;
}
.lift-copy { display: grid; gap: 4px; }
.lift-copy strong { font-size: 13px; letter-spacing: -0.01em; }
.lift-copy small { color: #68597f; font-size: 11px; }
@media (prefers-reduced-motion: reduce) {
.lift { transition: none; }
}
</style>
</head>
<body>
<main class="demo">
<button class="lift" type="button" aria-pressed="false">
<span class="lift-art" aria-hidden="true"><span></span></span>
<span class="lift-copy"><strong>Afternoon plans</strong><small>Product photography</small></span>
</button>
</main>
<script>
const card = document.querySelector(".lift");
card.addEventListener("click", () => {
const lifted = card.getAttribute("aria-pressed") === "true";
card.setAttribute("aria-pressed", String(!lifted));
});
</script>
</body>
</html>Original example by UI Skills