我有任意数量的 <div>
元素。我想要每个 <div>
旋转,但增加 2 度。应该怎么做?我不确定仅在 CSS 中是否可行,
例如:
div:nth-child(1) {
rotate(0deg);
}
div:nth-child(2) {
transform: rotate(2deg);
}
div:nth-child(3) {
transform: rotate(4deg);
}
...
// Here is the general equation, but I can't use it in CSS.
div:nth-child(n) {
transform: rotate( 2*n );
}
最佳答案
试试这个:
$qty: 40;//number of childs
$step: $qty *2 ;
@for $i from 0 through $qty - 1 {
div:nth-child(#{$i + 1}) {
transform: rotate( $step+deg) ;
}
}
关于css - 以递增的量旋转元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29047525/