CSS Master

(Primo) #1
Figure 1.36. Using the step An+B microsyntax to select items 8 through 20

Negative Offsets
Negativeoffsetandrangevaluesarealsovalid.Using:nth-child(-n+8)would
invertourselection,andmatchthefirsteightelements.

Wecanalsousetheoffsetandstepvaluestoselecteverythirdelement,starting
withthefifth:

.item:nth-child(3n+5) {
background: #e91e63;
}

YoucanseetheresultsofthisselectorinFigure1.37.

54 CSS Master

Free download pdf