关于:nth-of-type() 的问题
:nth-of-type(n) 时css3新增的选择器;
同级层同类型的元素的第n个元素;可以传数字,2n,3n…
<div class="listBox">
<h3></h3>
<img src="img/02.png" alt="">
</div>
<div class="listBox">
<h3></h3>
<img src="img/02.png" alt="">
</div>
<div class="listBox">
<h3></h3>
<img src="img/02.png" alt="">
</div>
例如:下列代码无效
.listBox h3:nth-of-type(2){
background:red; /*无效???*/
}
:nth-of-type() 表示同级同类型的元素查找
所以应该写成:
.listBox:nth-of-type(2) h3{
background:red; /*背景变红*/
}