Sass mixin两种颜色之间的调色板

时间:2017-07-29 06:30:43

标签: colors sass

我需要在Sass中创建一个包含3个参数的mixin($ startingColor,$ endingColor和$ n-要创建的块数)。它必须是这两种颜色之间的色调过渡(调色板)。任何人都可以帮助我吗?:)

1 个答案:

答案 0 :(得分:1)

好吧,我半小时前收到了这个问题但后来我意识到了sass的mix()函数。经过一番头脑风暴后,它会在这里为你服务;

@mixin tonal-transition($x, $y, $c){
  @for $i from 1 through $c {
    > * {
      &:nth-of-type(#{$i}) {
        background: mix($y, $x, 100% * $i/$c);
      }
    }
  }
}

here is codepen

相关问题