css 中 nth-child、first-child、last-child 的使用(选中第一个,第几个,第几个到第几个,最后一个等)
li:first-child{color:red}
li:last-child{color:pink}li:nth-child(3){color:pink}li:nth-child(2n){color:pink}
li:nth-child(2n-1){color:pink}li:nth-child(n+4){color:pink}7. 选择从第一个到第四个 这里的数字4也是可以根据你的需要替换的。
li:nth-child(-n+4){color:pink}8.nth-last-child(3) 表示最后三个标签
li:nth-last-child(3){color:pink}9.nth-last-child(3n) 表示3的倍数3.6.9……
li:nth-last-child(3n){color:pink}10.nth-last-child(3n-1) 表示2.5.8…… 可以用这个设置等差数列的样式
li:nth-last-child(3n-1){color:pink}希望有帮到你。