<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/ –