我试图在另一个 mixin 中调用一个 mixin 作为参数,但我得到一个语法错误。有问题的 mixin 调用中没有变量,只有参数。
我不确定这是否可能。我在这里看到的答案似乎是黑客或将变量和字符串作为参数处理。
更少的 CSS
// color variables for user's color
@userColor: #13acae;
@darkUser: hsl(hue(@userColor), saturation(@userColor), lightness(tint(@userColor, 30%)));
@lightUser: hsl(hue(@userColor), saturation(@userColor), lightness(shade(@userColor, 30%)));
// color mixin to alter user's color using Less 'darken' and 'contrast' functions
.contrastColorDark(@percent) { color: darken(contrast(@userColor, @darkUser, @lightUser), @percent); }
// border mixin
.border(@width, @color) { border: @width solid @color; }
// CSS rule using both mixins
.thing {
.border(1px, .contrastColorDark(10%));
}
错误(在前面的点处.contrastColorDark(10%)
)
SyntaxError: expected ')' got '.'
我想要实现的目标:我试图让框边框颜色与其中使用对比度混合的某些元素相匹配。