Quantity Queries

By Chris Coyier on August 5, 2015 in Web Design

Using :nth-child (and friends), you can write selectors that target elements when they have a certain number of siblings. So you can write CSS that, for example, styles widgets to be 33.33% wide if there are exactly 3 of them.

The selectors are a bit complicated though, so this tool by Drew Minns is pretty helpful.

And perhaps controversially, a PostCSS plugin for the same.

Direct Link to ArticlePermalink

Quantity Queries is a post from CSS-Tricks