2017-07-29 79 views
2

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

+1

请分享您迄今尝试过的代码示例 – Nora

回答

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

+0

非常感谢!:) – Lorre

+0

所以我认为您应该接受答案并关闭主题。它似乎仍然开放。 – pacanga