细节
- 直接给a元素设置样式,相当于给a元素的所有动态伪类都设置了
■相当于a:link , a:visiitd , a:active , a:focus的color都是red
结构伪类(structural pseudo classes)-:nth-child()
■:nth-child(1)
□是父元素中的第1个子元素
结构伪类-:nth-child()
■:nth-child(2n)
□n代表任意正整数和0
□是父元素中的第偶数个子元素(第2 , 4 , 6 , 8……个)
□跟:nth-child(even)同义
结构伪类-:nth-last-child()
■:nth-last-child()的语法跟nth-child()类似,不同点是:nth-last-child()从最后一个子元素开始往前计数
□:nth-last-child(1),代表倒数第一个子元素
□:nth-last-child(-n+2),代表最后2个子元素
结构伪类-:nth-of-type()、:nth-last-of-type()
■:nth-last-of-type()用法跟:nth-of-type()类似
□不同的是:nth-last-of-type()从最后一个这种类型的子元素开始往前计数
结构伪类
■:first-child,等同于:nth-child(1)
■:last-child,等同于:nth-last-child(1)
■:first-of-type,等同于:nth-last-of-type(1)
■:only-child,是父元素中唯一的子元素
■:root,根元素,就是HTML元素
结构伪类-:empty
■:empty代表里面完全空白的元素