css---5 only-child or nth-of-type
1 _nth-child系列 :nth-child(index) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>nth-Child</title> <style type="text/css"> ul > li:nth-child(3) { background: #f00; } /* ul > li:nth-child(2n) { background: #ff0; } ul > li:nth-child(2n+1) { background: #0f0; } ul > li:nth-child(n+4) { background: #abcdef; } ul > li:nth-child(odd) { background: red; } ul > li:nth-child(even) { background: blue; } */ </style> </head> <body> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> <hr> <div>0-1</div> <div>0-2</div> <div>0-3<