我正在尝试在 Sass 中创建一个 mixin 以用于 :hover 操作,但我无法使其工作。
我声明 mixin:
@mixin hover($action, $color, $amount) {
color: $action($color, $amount);
}
我的想法是使用Sass 脚本函数 http://sass-lang.com/documentation/Sass/Script/Functions.html#darken-instance_method通过基本上变亮或变暗来更改悬停时链接的颜色。例如我尝试:
a {
&:hover {
@include hover(darken, $footer-text-color, 5%);
}
}
$footer-text-color
是我之前定义的一个变量,它等于十六进制颜色,例如#84b3c8。
我希望这与
a {
&:hover {
color: darken($footer-text-color, 5%);
}
}
相反,它用纯 CSS 编译的内容是:
color: darken #84b3c8, 5%;
很明显,颜色功能不起作用,但真诚地我不明白为什么。我确信这很愚蠢,也许是 mixin 参数中变量和字符串值的混合?