CSS prefers-reduced-motion Media Query

Publikováno: 30.7.2019

When I started in the web development industry, media queries were limited — screen and print were the two media queries I was most often using. More than a decade later, media queries have advanced to various screen units, feature checking, and even color scheme preference. I’ve been so happy to see CSS evolve beyond […]

The post CSS prefers-reduced-motion Media Query appeared first on David Walsh Blog.

Celý článek

When I started in the web development industry, media queries were limited — screen and print were the two media queries I was most often using. More than a decade later, media queries have advanced to various screen units, feature checking, and even color scheme preference. I’ve been so happy to see CSS evolve beyond incredibly generic settings.

One of the CSS media queries I’ve recently discovered is prefers-reduced-motion, a media query for users sensitive to excessive motion.

Let’s use prefers-reduced-motion to show motion to all users but none to sensitive users:

.animation {
  animation: vibrate 0.2s; 
}

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

The example above illustrates how we can cater to sensitive users by not animating elements for those who have said they don’t want them.

It’s amazing how media queries like this can really show users that you care. Sure, we love the fancy razzle-dazzle but not everyone can handle that motion.

The post CSS prefers-reduced-motion Media Query appeared first on David Walsh Blog.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace