1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> li:nth-child(1){ background-color: red; } li:nth-child(2){ background-color: red; } li:nth-child(2n-1){ background-color: red; }
li:nth-of-type(3){ background-color: blue; } li:nth-of-type(4){ background-color: blue; } </style> </head> <body> <ul> <li>列表1</li> <p>段落1</p> <li>列表2</li> <li>列表3</li> <p>段落2</p> <li>列表4</li> <li>列表5</li> <li>列表6</li> <p>段落3</p> <li>列表7</li> <li>列表8</li> <li>列表9</li> <li>列表10</li> <p>段落4</p> <p>段落5</p> <p>段落6</p> </ul> </body> </html>
|