css - 以递增的量旋转元素

标签 css sass css-animations

我有任意数量的 <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) ;
  }
}

also check this

关于css - 以递增的量旋转元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29047525/

相关文章:

jquery - CSS3 动画 - 无限旋转高分辨率图像,框阴影脉冲发光

css - 如何为crossrider中 'appAPI.openURL'打开的html页面设置css

javascript - 复合网页动画

html - 在具有 BG 颜色的 div 顶部添加图像

html - IE11 : Text of input field slips below the bottom border

css - 如何从用逗号(,)分隔的css中取出公因数

ruby-on-rails - 分析开发中的缓慢 Assets

html - 对不应该在 div 中旋转的文本进行故障排除

PHP 隐藏/显示带分页的图像

html - 使用 Flexbox 时顶部被切断