Variables SASS-创建新的$variable并将其值转换为新的$variable

Variables SASS-创建新的$variable并将其值转换为新的$variable,variables,sass,interpolation,Variables,Sass,Interpolation,我试图实现的是,将每个$variable放入一个混合了白色和颜色$var的函数中,使其更轻一些 我无法做到这一点,因为到目前为止我对sass缺乏了解 因此,问题是: 为什么我能在我的插值上赚到美元,而我却能使它成为一门课 实现这一目标的更好方法是什么 $red : #F4493C; $blue : #2196F3; $white : #FFFFFF; $red-50 : #ffcccc; // <-- this is what it should result in..

我试图实现的是,将每个$variable放入一个混合了白色和颜色$var的函数中,使其更轻一些

我无法做到这一点,因为到目前为止我对sass缺乏了解

因此,问题是:

为什么我能在我的插值上赚到美元,而我却能使它成为一门课

实现这一目标的更好方法是什么

$red     : #F4493C;
$blue    : #2196F3;
$white   : #FFFFFF;
$red-50  : #ffcccc; // <-- this is what it should result in...

$colors:(
  red,
  blue
);

/* how the function should work
@function colortint($color, $white, $amount){
  @return mix($color, $white, $amount);
}
*/

@function colortint($color, $white){
  @return mix($color, $white, 20%);
}

body {
  background-color: colortint($red, $white);  
}

@each $color in $colors {
.#{$color} {
   background-color: colortint($color, $white); // giving it a classworks
  }
}

/* this is what i want
@each $color in $colors {
  ${$color}-50 : colortint($color, $white, 20%); // why can't i make it a variable
}
*/
$red:#F4493C;
$blue:#2196F3;
$white:#FFFFFF;

$red-50:#ffcccc;//为了简化这个具体案例,SASS内置了lighte()和darken()函数——尽管这可能无法解决您的实际问题:)lighte()和darken()的问题可能重复,这不是线性的,通过混合白色,您可以实现线性变化。不,这不是我的问题:)叶,你说得对。谢谢:)该死的,这是个不错的功能。