【发布时间】:2015-01-14 09:40:42
【问题描述】:
有没有办法使用nth-child(n)中的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;
}
【问题讨论】:
-
如果你使用
preprocessor,例如sass -
...或者用jquery添加: $('div').each(function(i=1){$(this).css("top", -5*i); i++;});
标签: css attributes css-selectors increment