Hacker News new | ask | show | jobs
by extra88 1757 days ago
> What if you have odd even, every third etc

The solution is the same. `:nth-child(3n)` selects every third so you add the :not(:last-of-child) to the end to prevent it from being matched by the rule.

    .card:nth-child(3n):not(:last-of-child) {
      /* styles for every third card, not the last card */
    }
What's less clear to me is why `.card + .card` would be better for applying a style to all but the first card than `.card:not(:first-child)`. I think there are reasons for not using `*:not(:first-child)` and preferring the "lobotomized owl" `* + *` but my hunch is they don't apply when styling classes.