可中断动效 · 按压缩放 · 进出场 · 图标动效纪律 · 动效克制 — 与「界面质感」的静态规则互补。
| CSS 过渡 | CSS 关键帧 | |
|---|---|---|
| 行为 | 朝最新状态插值 | 固定时间线跑完 |
| 被打断 | 中途改向、平滑反演 | 跳变或从头重放 |
| 用途 | hover / toggle / 开合 | 一次性的序列(进场、加载) |
.drawer{ transform:translateX(-100%); transition:transform 200ms ease-out; }
.dwer.open{ transform:translateX(0); } /* 中途再点会平滑反转 */
/* 坏:.open 用 animation 关键帧,关到一半会 snap */
点击时轻微缩到 0.96,绝不小于 0.95(更小显得夸张)。用过渡保证可中断:松手中途也能平滑回弹。
.button{ transition-property:scale; transition-duration:150ms; transition-timing-function:ease-out; }
.button:not(:disabled):active{ scale:.96; }
scale(.96),给按钮加 static 属性在会分心时关掉。opacity + blur(4px) + translateY(12px)。.stagger-item{ animation:fade-in 300ms ease-out both; }
@keyframes fade-in{ from{ opacity:0; transform:translateY(12px); filter:blur(4px);} }
@media (prefers-reduced-motion: no-preference){ .stagger-item{ animation-name:fade-in-up; } }
translateY(-12px)+blur(4px),150ms(进场 300ms)。用户注意力已移向下一处,别抢戏。需保留空间含义时(卡片回列表、抽屉关)才整段滑出(x:-100%,200ms)。上下文出现的图标(hover 显现、状态切换)用 opacity + scale + blur 交叉淡入,禁用其它值:
| 属性 | 起→止 |
|---|---|
| scale | 0.25 → 1(绝不用 0.5/0.6) |
| opacity | 0 → 1 |
| filter | blur(4px) → blur(0px) |
| transition | { type:'spring', duration:0.3, bounce:0 } —— bounce 恒为 0 |
// 无 motion 依赖:两图标同 DOM 交叉淡ActiveInactive
motion 从 motion/react 引,装了 framer-motion 从它引,两者皆无就用 CSS 交叉淡——别为图标动效加依赖。| 该动 | 不该动 |
|---|---|
| hover 才出现的动作图标 | 静态导航图标 |
| 状态切换(播放↔暂停、赞↔已赞) | 装饰图标 |
| 上下文工具栏图标 | 始终可见的图标 |
.panel{ transition:opacity 150ms ease-out; }
@media (prefers-reduced-motion: no-preference){
.panel{ transition-property:opacity, translate, scale, filter; transition-duration:300ms; }
}
Tailwind 里给位移/缩放/模糊加 motion-safe: 前缀;Motion 用 <MotionConfig reducedMotion="user">(保留 opacity,关掉 transform/layout,blur 仍需按 useReducedMotion() 分支)。