好比: selecor:first-childcss
不要费力去理解他们到底为了解决什么问题, 是对集合进行操做仍是怎么怎么着, 记住这么一个规则: 若是 selector:first-child 生效, 须要: **selector.parent.children.first == selector;**
也就是: 当前元素的父元素的第一个子元素就是它自己, 此时, selector:first-child 才会生效.html
同理:
selector:last-child, 须要:css3
selector.parent.children.last == selector; 才会生效
nth-child()
注意这里的 n 有很大发展空间, 能够实现 奇/偶, 选择哪几个, 从哪几个开始选.code
nth-last-child() 倒着选htm
:first-of-type
:last-of-type文档
:nth-of-type
:nth-last-of-typeio
:root
选择文档根元素.就是 html
:empty
选择元素中连个空格都没有的元素
:not
否认选择器
:only-child
在集合只有一个元素的时候才会生效.
::selection
只能设置两个属性:background,color.ast