Skip to content

Instantly share code, notes, and snippets.

@Luke-SNAW
Last active March 1, 2022 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luke-SNAW/806472d336b1117f1b2ab6e7ae8e7d6c to your computer and use it in GitHub Desktop.
Save Luke-SNAW/806472d336b1117f1b2ab6e7ae8e7d6c to your computer and use it in GitHub Desktop.
[CSS] #collections #css
  • justify-content vs column-gap
  • justify-content and align-items vs margin: auto
  • flex items are blockified

Notice that we’re advised to make target sizes at least 44×44 pixels, which is mentioned no fewer than 18 times in the WCAG 2.5.5 explainer.

Handle resources

For years, my go-to recommendation for CSS animations was animate.css by Daniel Eden.

It’s a great library, but it also a library. I generally only need one or two animations, and it includes way more stuff than I typically want in a project.

So I was delighted to discover Animista by Ana Travis last week. Animista is a tool that lets you select the animation you want, and then copy/paste the CSS for it into your project.

Important accessibility concerns

Animations can make people who experience motion sickness, vertigo, and other conditions physically sick, dizzy, and disoriented.

Both Windows and macOS provide a way to disable animations at the operating system level, and tell websites that they would prefer not to see them as well.

We can access this setting through a CSS media query: prefers-reduced-motion.

@media (prefers-reduced-motion: reduce) {
  /* The user does not want animations */
}

@media (prefers-reduced-motion: no-preference) {
  /* The user is OK with animations */
}

TL;DR; Use @media-like @supports rule for feature detection in CSS, its equivalent - CSS.supports() in JS, and library like Modernizr when those feature detections aren’t supported (e.g. IE).

Scroll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment