相关疑难解决方法(0)

有没有办法在 :nth-child(n) 中使用“n”值?

我想创建一个折叠效果。

小提琴

有4张蓝卡,所以我创建了4个类来设置位置。我想让它更聪明,以防有超过 4 张卡。在 CSS 中,我尝试了这个。

.card:nth-child(n){
    position: absolute;
    left: calc(n*10)px;
    top: calc(n*10)px;
}
Run Code Online (Sandbox Code Playgroud)

但是,它不起作用。有没有办法做到这一点?

html css css-selectors

12
推荐指数
3
解决办法
4997
查看次数

css增加nth-child属性值

有没有办法使用n in增加属性值nth-child(n)来输出结果:

div:nth-child(1){
    top: -5px;
}
div:nth-child(2){
    top: -10px;
}
div:nth-child(3){
    top: -15px;
}
div:nth-child(4){
    top: -20px;
}
div:nth-child(5){
    top: -25px;
}
Run Code Online (Sandbox Code Playgroud)

css attributes increment css-selectors

7
推荐指数
1
解决办法
3313
查看次数

标签 统计

css ×2

css-selectors ×2

attributes ×1

html ×1

increment ×1