Pointer Tilt Card (3D with Glare) new 鼠标驱动的 3D 倾斜 web
A panel leans toward the pointer in 3D while a highlight slides across it, as if light were catching real glass
面板跟着鼠标在 3D 里倾斜,高光随之滑过,像光照在真的玻璃上
in glass. Get started
rotateX 0° · rotateY 0° · glare 50% 50%
标本可交互,可以直接操作。
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Tilt倾斜
rotateX / rotateYPointer position maps to a small rotation toward the pointer.
鼠标位置映射为朝向鼠标的小角度旋转。
Prompt fragmentPrompt 片段rotateY ±18° and rotateX ±14° from pointer position
按鼠标位置 rotateY ±18°、rotateX ±14°
-
2 Depth layers深度分层
translateZText and back plate sit at different depths for parallax.
文字和背板放在不同深度,形成视差。
Prompt fragmentPrompt 片段text at translateZ(36px) and a back plate at translateZ(-18px)
文字 translateZ(36px)、背板 translateZ(-18px)
-
3 Glare高光
radial-gradientA soft highlight follows the pointer across the surface.
一块柔和高光跟着鼠标滑过表面。
Prompt fragmentPrompt 片段a screen-blended radial-gradient highlight at the pointer
以鼠标为中心的 screen 混合径向渐变高光
-
4 Reset复位
easingThe card eases back to flat when the pointer leaves.
鼠标离开时卡片缓动回平。
Prompt fragmentPrompt 片段the card easing back to flat on pointerleave
pointerleave 时缓动回平
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Build a pointer-driven tilt card: on pointermove over the stage, map pointer position across the card to rotateY (±18°) and rotateX (±14°) with perspective about 760px; smooth toward the target each frame; put the text layer at translateZ(36px) and a back plate at translateZ(-18px) with preserve-3d; draw a screen-blended radial-gradient glare centred on the pointer. Ease back to flat on pointerleave. Under prefers-reduced-motion keep the card flat.
做一个鼠标驱动的倾斜卡片:在舞台上 pointermove 时,把鼠标在卡片上的位置映射为 rotateY(±18°)和 rotateX(±14°),父级 perspective 约 760px;每帧平滑追向目标;文字层 translateZ(36px)、背板 translateZ(-18px),开启 preserve-3d;以鼠标为中心画一层 screen 混合的径向渐变高光。pointerleave 时缓动回平。prefers-reduced-motion 时保持不倾斜。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my tilt card. Check that perspective is on the parent, not the card; rotateX uses the vertical position and rotateY the horizontal one with the right signs (the card should lean toward the pointer); motion is smoothed rather than jumping per event; preserve-3d is not flattened by overflow or filters on the card; glare coordinates match the pointer; the card resets on pointerleave and touch; and reduced motion disables tilting. The symptom:
调试我的倾斜卡片。检查:perspective 是否加在父级而不是卡片上;rotateX 用纵向位置、rotateY 用横向位置,方向是否正确(卡片应朝鼠标倾斜);动画是否平滑而不是每个事件跳一下;卡片上的 overflow 或 filter 是否把 preserve-3d 压平了;高光坐标是否与鼠标一致;鼠标离开和触摸时是否复位;以及减少动态效果时是否关闭倾斜。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| CSS | perspective + rotateX() / rotateY() | tilt the card in 3D from pointer position按鼠标位置让卡片在 3D 里倾斜 |
| CSS | transform-style: preserve-3d + translateZ() | float inner layers at different depths让内部各层浮在不同深度 |
| CSS | radial-gradient at a moving position | the glare highlight that follows the pointer跟随鼠标移动的高光 |
| JS | vanilla-tilt.js | a small library with max tilt, glare and reset options一个支持最大角度、高光和复位的小库 |