学习库CSSMotion and Interaction

Motion and Interaction

Use transitions, transforms, and animation to explain change without causing friction.

更新于 适用于 Modern CSS

Motion should clarify cause and effect: what changed, where it moved, or which element is active. It should not delay access to content or make interaction harder.

Transition state changes

button.css
.button {
  transition: transform 160ms ease, background-color 160ms ease;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 3px solid #f46537; outline-offset: 3px; }

Name the properties instead of using transition: all. Transforms and opacity are generally efficient and do not reflow surrounding layout.

Create a purposeful animation

status.css
@keyframes pulse {
  50% { opacity: 0.45; }
}
.loading-dot { animation: pulse 900ms ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .loading-dot { animation: none; }
}

Animation needs a clear resting state. Infinite motion should be rare and easy to avoid through reduced-motion preferences.

Interaction states are a set

Design default, hover, focus-visible, active, disabled, selected, loading, and error states together. Hover is unavailable on many touch devices and cannot be the only path to information.

Keep this

Animate a reason, keep durations short, preserve focus visibility, and provide a calm reduced-motion experience.

学习位置已保存在此设备上。