Figure 1.34. Using :nth-child() to select a single item by its index
Butwhatifwewanttoselecteverythirdelement?Here’swheretheAn+Bsyntax
comesin:
.item:nth-child(3n) {
background: #e91e63;
}
Again,Aisastepinterval.It’salmostlikeamultiplierforn,whichstartsat1.So
ifA=3,then3nwouldmatchthe3rd,6th,9th,andsoonelements.That’sexactly
whathappens,asyoucanseeinFigure1.35.
52 CSS Master