javascript - 在 Angular 选择器上使用 last-child

标签 javascript html css angularjs

如何让 last-child CSS 选择器在 Angular 组件选择器上工作?我想将样式添加到具有特定类的最后一个组件项。

我的 HTML:

<component-name class="abc"></component-name>
<component-name class="abc"></component-name>
<component-name class="abc"></component-name>
<component-name class="efg"></component-name>
<component-name class="efg"></component-name>

在上面的例子中,我想为最后一个 .abc 元素设置样式。所以我的 CSS:

component-name.abc:last-child {
 // some styles
}

这行不通。这也不是:

component-name.abc:last-of-type {
    // some styles
}

在这种情况下,如何选择最后一个 child ?

最佳答案

您在 component-name.css 文件中发布的 css 代码吗?如果是这种情况,请将其移至父组件样式表或 style.css

关于javascript - 在 Angular 选择器上使用 last-child,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48299007/

相关文章:

javascript - 如何在 ng-repeat 中显示接下来的 15 个项目?

javascript - 我无法将参数动态传递给 javascript 中的 html 标签

javascript - polymer 阵列错误

PHP HTML to PDF mikehaertl/phpwkhtmltopdf 页面大小问题

css - 如何最大 float 网格元素的高度

html - 如何使幻灯片标题响应并在页面最小化时消失?

javascript - 使用 Fluent-ffmpeg 将包含空格的选项传递给 ffmpeg

html - Bootstrap 拉柱包装

javascript - 根据输入动态插入表值?

html - 自定义边框 css 和背景图片