相关疑难解决方法(0)

CSS last-child选择器:选择特定类的last元素,而不是父类中的最后一个子元素?

<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

的jsfiddle

html css css-selectors css3

157
推荐指数
7
解决办法
23万
查看次数

标签 统计

css ×1

css-selectors ×1

css3 ×1

html ×1