原标题:HTML5选择符
div{……}、div.class{……}、div#id{……}、div span{……}、div[class="classname"]{}
但是由于ie某些浏览器的原因,很多好用的选择符不能广泛使用,如ie6只支持a标签的伪类选择符,但是在移动端,我们就不用在意这些了,绝大多数选择符都已经可以使用了,如前文已经用到的
.item_list li:first-child{background: #f00}
.item_list li:nth-child(2){margin-left: 10px;background: #ff0;-webkit-box-flex:1;}
.item_list li:last-child{background: #c96}
伪类选择符和伪对象选择符有很多,灵活运用可以减少很多不必要的代码。如E:nth-child(n){ …… }、E:nth-of-type(n){ …… }、E:disabled{ …… }、E:empty{ …… }、E:first-letter/E::first-letter{ …… }、E:first-line/E::first-line{ …… }、E:before/E::before{ ……}、E:after/E::after{…… }、E::selection{ …… }等,这里不细说。
责任编辑: