html - 如何为多级html属性创建nth-child CSS
问题描述
我目前有一个可以将小部件插入 DOM 的屏幕。我想根据出现类decrement-z-index
存在的数量来设置 z 索引。
我写了这个类来尝试实现这一点
.tblrow > .tblcell > div > .decrement-z-index:nth-child(1) {
z-index: 200 !important;
}
.tblrow > .tblcell > div > .decrement-z-index:nth-child(2) {
z-index: 199 !important;
}
.tblrow > .tblcell > div > .decrement-z-index:nth-child(3) {
z-index: 198 !important;
}
.tblrow > .tblcell > div > .decrement-z-index:nth-child(4) {
z-index: 198 !important;
}
[![enter image description here][1]][1]
这里有一个 jsFiddle http://jsfiddle.net/r6axhgy2/
当检查任何元素时,decrement-z-index
它们都声明它是第 2 次出现
请问我如何在这里正确实现nth-child,以便正确选择nth-child
解决方案
你nth-child
在错误的位置使用下面的代码,希望它对你有帮助
.tbl .tblrow:nth-child(1) .decrement-z-index {
z-index: 200 !important;
}
.tbl .tblrow:nth-child(2) .decrement-z-index {
z-index: 199 !important;
}
.tbl .tblrow:nth-child(3) .decrement-z-index {
z-index: 198 !important;
}
.tbl .tblrow:nth-child(4) .decrement-z-index {
z-index: 197 !important;
}
推荐阅读
- r - 有没有一个函数可以接近() %in% 是 == 吗?
- java - java火花1.6 csv文件
- python - Odoo 11如何覆盖one2many字段的自动生成模式视图
- sql - SQL Server:计算一条记录可以应用于表的次数
- c# - 如何在 C# 中使用 mailkit 在草稿中添加字节 [] 附件
- jenkins - 有没有办法在有条件的情况下跳过整个 Jenkins 流水线(不是阶段)
- windows - 你能用 AutoHotkey 绑定一个键来最小化所有打开的窗口吗?
- python - 如何按单元格/元素将自定义函数应用于两个数据框?
- r - R:Renderui 没有正确初始化
- javascript - 在浏览器中保存无法在选项卡之间共享的数据的最佳方法?