CSS Master

(Primo) #1
Figure 1.33. A document of 20 div elements

With:nth-child()and:nth-last-child(),wecanselectasinglechildatapar-
ticularposition.Wecanselectallofthechildrenafteraparticularposition,orwe
canselectelementsbymultiples,withanoffset.Let’schangethebackgroundcolor
ofthesixthitem:


.item:nth-child(6) {
background: #e91e63;
}

ThisgivesustheresultinFigure1.34.


Selectors 51

Free download pdf