html - CSS- :last-child that has "xyz" class name selector? 纯 CSS/LESS

标签 html css dom

我知道 last-child 是它 parent 的最后一个 child 。

<div class"parent">
    <div class="child a"></div>
    <div class="child b"></div>
    <div class="child c"></div>
    <div class="child d"></div>
    <div class="child d"></div>
    <div class="child d"></div>
    <div class="child d"></div>
    <div class="child e"></div>
</div>

这里,

.child:last-child{
    /*This will grab .child.e  as it's the last child of it's parent*/
}

我想使用 :last-child 选择器选择最后一个 .child.d。 (最后一个 .childd 类)? 什么是 CSS 选择器? (请不要使用 Javascript!)

最佳答案

:last-of-type 对我不起作用 我正在写 postCSS。由于某种原因,这不起作用

.roomOffered{
    &__single{
        border-bottom: 1px solid $color__skipper--fade3;
        padding: 3.5rem 0 3rem;
        margin-bottom: 0;
        &:last-of-type{
            border-bottom: none;
        }
    }
}

最后一个 .roomOffered__single 的 border-bottom 没有被移除!!

关于html - CSS- :last-child that has "xyz" class name selector? 纯 CSS/LESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37031554/

相关文章:

javascript - 如何将 SQL Server 中的数据绑定(bind)到 HTML 页面?

javascript - jQuery 1.6.1 连续背景颜色动画请求失败

html - CSS 中带有静态图像的静态页脚?

css - 如何在 spring MVC 应用程序中为不同的 URL 加载 CSS

javascript - 如何在单击按钮时使图像旋转

javascript - 溢出未隐藏但不透明度已更改

css - 正常显示截断的文本,但在悬停时显示全文

html - 如何使用 css 通过 href#id 隐藏 anchor 标记

javascript - node.nextSibling 和 ChildNode.nextElementSibling 有什么区别?

javascript - 使用 JavaScript 阻止 DOM 解析