Styles & Effects
Hover Effects
CSS / JS
Browser E2E & Sandbox Verified
3D Specular Hover Tilt Card
Pointer-tracking 3D perspective card with a dynamic radial specular highlight and automatic prefers-reduced-motion fallback.
Sandboxed Live Preview
Isolated iframe (CSP + no same-origin)Interactive live preview — move your pointer across the card to inspect the 3D tilt and specular highlight.
Source Code (3 files)
<div class="tilt-stage">
<article class="tilt-card" data-otter-tilt>
<div class="tilt-eyebrow">Interactive Effect</div>
<h3>3D Specular Surface</h3>
<p>Move your cursor across this card to track pointer depth and radial light reflection.</p>
</article>
</div>
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; }
.tilt-stage {
min-height: 240px;
display: grid;
place-items: center;
padding: 20px;
background: #0b162a;
perspective: 900px;
}
.tilt-card {
position: relative;
width: min(330px, 100%);
padding: 24px;
border-radius: 18px;
color: #f8fafc;
background: linear-gradient(145deg, #172d52, #0f1d36);
border: 1px solid rgba(148, 163, 184, 0.28);
box-shadow: 0 22px 44px rgba(2, 6, 23, 0.45);
transform-style: preserve-3d;
transition: transform 120ms ease-out;
overflow: hidden;
}
.tilt-card::after {
content: '';
position: absolute;
inset: 0;
pointer-events: none;
background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(125, 211, 252, 0.25), transparent 55%);
opacity: var(--glare, 0);
transition: opacity 180ms ease;
}
.tilt-eyebrow {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #38bdf8;
}
.tilt-card h3 { margin: 10px 0 8px; font-size: 20px; }
.tilt-card p { margin: 0; font-size: 14px; line-height: 1.5; color: #cbd5e1; }
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!reducedMotion) {
document.querySelectorAll('[data-otter-tilt]').forEach((card) => {
card.addEventListener('pointermove', (event) => {
const rect = card.getBoundingClientRect();
const px = (event.clientX - rect.left) / rect.width;
const py = (event.clientY - rect.top) / rect.height;
const rx = (0.5 - py) * 14;
const ry = (px - 0.5) * 14;
card.style.transform = `rotateX(${rx.toFixed(2)}deg) rotateY(${ry.toFixed(2)}deg)`;
card.style.setProperty('--mx', `${(px * 100).toFixed(1)}%`);
card.style.setProperty('--my', `${(py * 100).toFixed(1)}%`);
card.style.setProperty('--glare', '1');
});
card.addEventListener('pointerleave', () => {
card.style.transform = 'rotateX(0deg) rotateY(0deg)';
card.style.setProperty('--glare', '0');
});
});
}
Installation & Usage
Copy tilt.html, tilt.css, and tilt.js into your project.
Add data-otter-tilt to any card element; tilt.js binds pointermove/pointerleave listeners while respecting prefers-reduced-motion.