CSS nth-child formula to select every 7th element and the 5th element

css, css-selectors

Solution

The formula is `:nth-child(7n+5)`. The `7n` represents "every 7th element" and the `+5` represents "starting from the 5th element".

More on `:nth-child()` in the Selectors spec.

Problem

So I'm creating a hexagon pattern with CSS3, and I'd like it to look like this; http://www.upperfirst.com I'm having my hexagons float:left in a body of a certain width. I can effectively accomplish the results in the link above if I can select the first element in every other row. What would be the nth-child formula for that? It would be the 5th element, then every 7th element after that?

Original source