Flexible Styles for
Variable Content

A Little About Me

Why Flexible Styles Are Important

  • Things change.
  • Flexibility.
  • Clients.

Why Use CSS?

  • Separation of concerns.
  • Independent of CMS.

How To Write Flexible Styles

Techniques and Use Cases

Flexbox

Literally short for "flexible box layout"

Cards using Floats

See the Pen WordCamp Example 1: Floated Cards by Adam Giese (@AdamGiese) on CodePen.

See the Pen WordCamp Example 2: Floated Cards w/ Height by Adam Giese (@AdamGiese) on CodePen.

Cards using Flexbox

See the Pen WordCamp Example 3: Flexbox Cards by Adam Giese (@AdamGiese) on CodePen.

More Resources on Flexbox

  • A Complete Guide to Flexbox by CSS-Tricks
  • What The Flexbox?! by Wes Bos
  • Flexbox Froggy by Codepip

Quantity Queries

li:first-child:nth-last-child(n+6),
li:first-child:nth-last-child(n+6) ~ li {...}

See the Pen WordCamp Example 4: Quantity Queries by Adam Giese (@AdamGiese) on CodePen.

More Resources on Quantity Queries

  • Some Extremely Handy `:nth-child` Recipes as Sass Mixins by ME! on CSS-Tricks
  • Quantity Queries for CSS by Heydon Pickering on A List Apart

The Future

Coming To A Browser Near You

CSS Grid

The Future of CSS Layout

More Resources on CSS Grid Layout

  • A Complete Guide to Grid by CSS-Tricks
  • Grid Garden by Codepip
  • Anything by Rachel Andrew or Jen Simmons.

Container Queries

A Potential New Approach to Responsive Design

The Concept

Media queries allow authors to vary the layout of their page based on the dimensions of the viewport. Container queries will allow developers to vary the layout within specific elements on a page (and their children) based on the dimensions of the parent elements themselves, allowing for much more modular approaches to layout.
The Responsive Issues Community Group

A (theoretical) example


.widget .social-links {...}
.widget:media(min-width: 300px) .social-links {...}

CSS Is Constantly Changing

Questions?

Slides available at: https://wcatx17.slides.rocks/

Thank You!