CSS3 常用选择器

 1  p:last-of-type{background-color: red;}  选择p中最后一项
 2 
 3  p:nth-of-type(2n){background-color: red;} 隔行变色里面也可以填写even 偶数变色 n 是计数器(从 0 开始)
 4    
 5  p:nth-of-type(2n+1){background-color: pink;} 隔行变色里面也可以填写odd 奇数变色 
 6 
 7  li:not(:last-child){border-right: 1px dashed black;} 选择全部排除最后一项,
8 :last-child
10 input[type^="text"]{ /**选择具有type属性且属性值为以text开头的字符串的input元素。**/ 11 background-color: red; 12 } 13 14 也可以写成[type^="text"] 这样范围更广一些 15 16 input[value$="按钮"]{ /**选择具有value属性且属性值为以按钮结尾的字符串的input元素。**/ 17 background-color:pink; 18 } 19 20 input[value*="按钮"]{ /**选择具有value属性且属性值为包含按钮的字符串的input元素。**/ 21 background-color: green; 22 } 23 24 div:before{display:block;content:"before伪类,前面插入内容";width: 70px;height: 60px;background-color:pink;} 25 div:after{content:"after伪类,后面插入内容";width: 60px;height: 70px;background-color: green;display:block;} 26 27 p:nth-of-type(5){background-color: pink;} 选择p元素里面第五个值
原文地址:https://www.cnblogs.com/Model-Zachary/p/6095347.html