是否可以使用CSS3选择器:first-of-type选择具有给定类名称的第一个元素?我的考试没有成功,所以我认为不是吗?
代码(http://jsfiddle.net/YWY4L/):
p:first-of-type {color:blue}
p.myclass1:first-of-type {color:red}
.myclass2:first-of-type {color:green}
<div>
<div>This text should appear as normal</div>
<p>This text should be blue.</p>
<p class="myclass1">This text should appear red.</p>
<p class="myclass2">This text should appear green.</p>
</div>
.myclass1选择将选择的每一个元素.myclass1。选择器.myclass1 ~ .myclass1使用通用的同级组合器来选择具有class的每个元素,该元素是class.myclass1为的元素的同级元素.myclass1。这在这里得到了惊人的详细解释。