Перейти до основного вмісту
← 🎨 CSS as a design system·Модуль B7 · Урок 11
ЗавданняAdd the canonical reduced-motion override at the end of CSS. Plus add a pulse animation on .heart, and a hover transition on .card. The override should kill both for opted-out users.

віддає перевагу примусу зі зниженим рухом

75 XP5 min
Теорія

The full reduced-motion override

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

This block goes at the END of your stylesheet (so it overrides everything). Wipes:

  • All animations to ~0ms (essentially instant) — preserves animationend events.
  • All transitions to ~0ms.
  • Smooth scroll behavior.

Why not just animation: none?

Some libraries rely on animationend event firing. Setting duration to 0.01ms guarantees the event still fires (it just fires almost-instantly). animation: none would skip the event entirely and break the library.

Per-element exceptions

If you have ONE animation that's content (not decoration) — a chart that animates in real time, a video — you can opt back in:

.chart-animation { animation: chart 2s ease-in-out !important; }

But check whether it's truly content. Most "marketing-feel" animations should follow reduced-motion.

Test it

Mac: System Settings → Accessibility → Display → Reduce motion.

Chrome DevTools: Rendering panel → "Emulate CSS media feature prefers-reduced-motion."

Run both your animations + a real reduced-motion test before shipping.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.