CSS 3D Tilt Card
A card that tilts toward the cursor in 3D using nine invisible hover zones instead of JavaScript.
Tilt me
Move your cursor around the card.
<div class="tilt">
<span></span><span></span><span></span>
<span></span><span></span><span></span>
<span></span><span></span><span></span>
<div class="tilt-card">
<h3>Tilt me</h3>
<p>Move your cursor around the card.</p>
</div>
</div>
.tilt {
--tilt: 10deg;
position: relative;
display: grid;
grid-template: repeat(3, 1fr) / repeat(3, 1fr);
width: 230px;
height: 150px;
perspective: 700px;
font-family: system-ui, sans-serif;
}
.tilt > span {
position: relative;
z-index: 2;
}
.tilt-card {
position: absolute;
inset: 0;
display: grid;
align-content: end;
padding: 18px;
border-radius: 18px;
background: linear-gradient(135deg, #f472b6, #8b5cf6 55%, #3b82f6);
box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.6);
color: #fff;
transition: transform 0.35s ease;
}
.tilt-card h3 {
margin: 0 0 4px;
font-size: 20px;
}
.tilt-card p {
margin: 0;
font-size: 13px;
opacity: 0.9;
}
.tilt > span:nth-child(1):hover ~ .tilt-card {
transform: rotateX(var(--tilt)) rotateY(calc(var(--tilt) * -1));
}
.tilt > span:nth-child(2):hover ~ .tilt-card {
transform: rotateX(var(--tilt));
}
.tilt > span:nth-child(3):hover ~ .tilt-card {
transform: rotateX(var(--tilt)) rotateY(var(--tilt));
}
.tilt > span:nth-child(4):hover ~ .tilt-card {
transform: rotateY(calc(var(--tilt) * -1));
}
.tilt > span:nth-child(5):hover ~ .tilt-card {
transform: scale(1.03);
}
.tilt > span:nth-child(6):hover ~ .tilt-card {
transform: rotateY(var(--tilt));
}
.tilt > span:nth-child(7):hover ~ .tilt-card {
transform: rotateX(calc(var(--tilt) * -1)) rotateY(calc(var(--tilt) * -1));
}
.tilt > span:nth-child(8):hover ~ .tilt-card {
transform: rotateX(calc(var(--tilt) * -1));
}
.tilt > span:nth-child(9):hover ~ .tilt-card {
transform: rotateX(calc(var(--tilt) * -1)) rotateY(var(--tilt));
}
@media (prefers-reduced-motion: reduce) {
.tilt-card {
transition: none;
}
.tilt > span:hover ~ .tilt-card {
transform: none;
}
}
About this CSS 3D Tilt Card
This CSS 3D Tilt Card is 85 lines of pure CSS (1.7 KB) with no JavaScript and no dependencies. It uses transitions, 3D transforms, transforms and linear gradients. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
- transitions
- 3D transforms
- transforms
- linear gradients
- box shadows
- CSS Grid
- custom properties
- reduced-motion support
Customize it
Change these custom properties to restyle the 3d tilt card without touching the rest of the CSS:
| Property | Default |
|---|---|
--tilt | 10deg |
How to use this 3d tilt card
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.tiltclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.