2016-12-15 113 views
-3

我有SASS代碼在裏面生成CSS類,這很好。它具有循環和簡單的數學表達式。將SASS數學表達式轉換爲LESS

我想將它轉換爲LESS,但我無法自己完成它。請看下面的代碼。

我該如何將這個轉化爲SESS所做的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)); 
     } 
    } 
} 
+0

你能代碼LESS簡單[循環](http://lesscss.org/features/#loops-feature)?管理變量的插值(以循環開始)? – FelipeAls

回答

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)