<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>
Run Code Online (Sandbox Code Playgroud)
我想选择#com19?
.comment {
width:470px;
border-bottom:1px dotted #f0f0f0;
margin-bottom:10px;
}
.comment:last-child {
border-bottom:none;
margin-bottom:0;
}
Run Code Online (Sandbox Code Playgroud)
只要我div.something在commentList中有另一个作为实际的最后一个孩子,那就不起作用了.在这种情况下是否可以使用last-child选择器来选择最后一次出现article.comment?