<div class="commentList">
<article class="comment " id="com21"></article>
<article class="comment " id="com20"></article>
<article class="comment " id="com19"></article>
<div class="something"> hello </div>
</div>
我想选择#com19
?CSS最后一个子选择器:选择特定类的最后一个元素,而不是父代中的最后一个子元素?
.comment {
width:470px;
border-bottom:1px dotted #f0f0f0;
margin-bottom:10px;
}
.comment:last-child {
border-bottom:none;
margin-bottom:0;
}
这并不工作,只要我有另一个div.something
作为commentList实际最后一个孩子。在这种情况下是否可以使用最后一个孩子选择器来选择article.comment
的最后一次出现?
它不看类,但是,只有类型,因此,如果您正好有你将同一类非文章得到意想不到的结 – BoltClock
事实上,正如在这里证明:http://jsfiddle.net/YmMZZ/1/ – Chris
它正常工作。但是,如果我们需要他们按类别缩小元素,那么它就不会再起作用。 http://jsfiddle.net/aliemreeee/a4H7f/2/ –