1、:last-child
比如:查找ul的最后一个li
ul li:last-child { //样式 }
2、:first-child
比如:查找ul的第一个li
ul li:first-child { //样式 }
3、:before和:after
使用它们来对一个元素前面和右面添加内容,可以是文字,也可以是图标
比如:添加图标
li:before{ background: url() no-repeat; content: " "; display: block; /* 图标高度 */ height: 13px; /* 图标宽度 */ width: 13px; }
:after和:before使用方法一样
4、:nth-child()
可以选择一个或多个特定的子元素
比如:nth-child(2)【第二个】、nth-child(n)【所有】、nth-child(2n)和:nth-child(even)【偶数】、nth-child(2n+1)和nth-child(odd)【奇数】、nth-child(n+2)【表示从第二个开始】,但是不能是负数