我想创建一个折叠效果。
有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)
但是,它不起作用。有没有办法做到这一点?
有没有办法使用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)