将SASS数学表达式转换为LESS

时间:2016-12-15 16:51:07

标签: css for-loop express sass less

我有SASS代码在其中生成CSS类,并且运行良好。它具有循环和简单的数学表达式。

我想将它转换为LESS但我无法自己完成它。请看下面的代码。

我怎样才能将其转换为SASS正在进行的LESS代码?

@for $i from 1 through (($point-count + 1) / 2) {
    &:nth-of-type(#{$i}) {
        transform: rotate(360deg / $point-count * ($i - 1));
    }

    &:nth-of-type(#{$i + $point-count / 2}) {
        transform: rotate(180deg + 360deg / $point-count * ($i - 1));
    }

    &:nth-of-type(#{$i}), &:nth-of-type(#{$i + $point-count / 2}) {
        &:before {
            animation-delay: - $spin-animation-time + ($spin-animation-time / $point-count * 2 * ($i - 1));
        }
    }
}

1 个答案:

答案 0 :(得分:0)

.loop(@i) when (@i < (@point-count + 1) / 2) {
    .loop((@i + 1));

    &:nth-of-type(@{i}) {
        transform: rotate(360deg / @point-count * (@i - 1));
    }

    @index: @i + @point-count / 2;

    &:nth-of-type(@{index}) {
        transform: rotate(180deg + 360deg / @point-count * (@i - 1));
    }

    &:nth-of-type(@{i}),
    &:nth-of-type(@{index}) {
        &:before {
            animation-delay: - @spin-animation-time + (@spin-animation-time / @point-count * 2 * (@i - 1));
        }
    }
}

.loop(1)