Creating a " Living " Card
Let's apply all acquired knowledge to create a card that responds to user.
.card {
--rotate-x: 0deg;
--rotate-y: 0deg;
transform: perspective(1000px) rotateX(var(--rotate-x)) rotateY(var(--rotate-y));
transition: transform 0.2s ease-out;
transform-style: preserve-3d;
}
.card:hover {
/* We change variables via JS (or via hover-zones),
and card smoothly tilts following mouse */
--rotate-x: 10deg;
--rotate-y: -10deg;
}
.card::after {
content: '';
position: absolute;
inset: 0;
background: radial-gradient(circle at var(--x) var(--y), rgba(255,255,255,0.4), transparent);
/* 'Glare' effect following cursor */
}
Why This Makes Interface Premium?
- Depth:
perspectiveadds 3D realism. - Responsiveness: Using variables makes animation dynamic.
- Optimization: All animations go through
transform, guaranteeing 60 FPS.
Tip
Don't overdo it. Good micro-interaction should be barely noticeable, like iPhone button " feedback " .