批改状态:合格
老师批语:
/* 选择器的权重id(千) > class(百) > tag(个)*//* tag 1个 权重 (0,0,1) */body {color: red;}/* tag 2个 权重 (0,0,2)*/body ul {background-color: aqua;}/* class 1个 权重 (0,1,0) */.list {background-color: chartreuse;}/* id 1个 权重 (1,0,0) */#b {background-color: coral;}


/* :first-of-type 匹配分组的第一个元素 */.list > li:first-of-type {background-color: aqua;}/* :last-of-type 匹配分组的最后一个元素 */.list > :last-of-type {background-color: darkorange;}/* :nth-last-of-type()反向匹配第三个元素a=0n=nb=3a*n+b=3*/.list > :nth-last-of-type(3) {background-color: deeppink;}/* 获取偶数索引元素a=2n=nb=0a*n+0=(2*0+0=02*1+0=22*2+0=42*3+0=6....以此类推)*/.list > :nth-last-of-type(2n) {background-color: chartreuse;}/* 获取奇数索引元素a=2n=nb=1a*n+1=(2*0+1=12*1+1=32*2+1=52*3+1=7....以此类推 */.list > :nth-last-of-type(2n + 1) {background-color: brown;}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号