html - Angularjs 表 nth-of-type

标签 html css angularjs css-selectors

我正在尝试使用 nth-of-type 更改包含 angularjs 表中行索引号的圆圈的背景颜色

html

<table class="section-table">
    <tr ng-repeat="defect in defects">
        <td width="10%"><div class="count-circle">{{$index + 1}}</div></td>
        <td width="40%">{{ defect.name }}</td>
        <td width="10%">
            <i style="color:#00C853" class="far fa-comment fa-lg"></i>&nbsp;&nbsp;{{ defect.defect_count }}
        </td>
        <td width="20%"><span class="pull-right">{{ defect.date }}</span></td>
        <td width="20%"><button class="btn-details pull-right">Details</button>
    </tr>
</table>

CSS

.section-table tr td div.count-circle:nth-of-type(5n+1) {
    background-color: blue;
}

.section-table tr td div.count-circle:nth-of-type(5n+2) {
    background-color: yellow;
}

.section-table tr td div.count-circle:nth-of-type(5n+3) {
    background-color: black;
}

我可以让 tr 改变颜色和 td 但我不能让 count-circle 类改变颜色,有人可以帮忙吗?

最佳答案

你正在重复 tr 所以你的代码应该是这样的:

.section-table tr:nth-of-type(5n+1) td div.count-circle {
    background-color: blue;
}

.section-table tr:nth-of-type(5n+2) td div.count-circle {
    background-color: yellow;
}

.section-table tr:nth-of-type(5n+3) td div.count-circle {
    background-color: black;
}

关于html - Angularjs 表 nth-of-type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49225198/

相关文章:

html - 中心背景图片

javascript - JS : Getting image id using onmouseover

javascript - 如何在 HTML 文件中分配图像

javascript - 删除jquery中的部分URL

html - 重新创建这个滚动页面效果

javascript - 可以设置输入类型=文件的文本框的高度吗?

javascript - 如何将标签的innerHTML渲染为嵌套HTML

javascript - Angularjs ui 路由器正则表达式

javascript - 如何在 AngularJS 中加载时停止过滤自定义过滤器

javascript - 一个页面上的多个 Iframe 加载问题