开发者

Rails 3.1 SCSS - Can I invoke SASS functions inside a SASS for loop?

开发者 https://www.devze.com 2023-04-12 04:40 出处:网络
I\'m setting up styles for a stacked bar graph, I would love to use SASS color manipulation functions to create the variations in a loop.Apparently I can\'t use SASS functions inside a for loop:

I'm setting up styles for a stacked bar graph, I would love to use SASS color manipulation functions to create the variations in a loop. Apparently I can't use SASS functions inside a for loop:

@for $i from 0 through 9{
  .Bar#{$i}{
    background-color:{mix(#75CFFF, #2C5999, #{i * 10}%)};
  }
}

The idea being that the color fades from 100% #75CFFF to 100% #2C5999 in 10 percent increments.

Is there any wa开发者_StackOverflow社区y to do this?


Got it.

@for $j from 0 through 4{
  .Bar#{$j}{
    @extend .Bar;
    background-color:mix($background-color, #2C5999, (10-$j)*10%);
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号