gpt4 book ai didi

sass - 无法将函数作为参数传递给混入

转载 作者:行者123 更新时间:2023-12-02 17:40:21 24 4
gpt4 key购买 nike

<分区>

我正在尝试在 Sass 中创建一个 mixin 以用于 :hover 操作,但我无法使其工作。

我声明了mixin:

@mixin hover($action, $color, $amount) {
color: $action($color, $amount);
}

我的想法是使用Sass Script Funcions通过基本上使链接变亮或变暗来更改悬停时链接的颜色。例如,我尝试:

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%;

很明显,颜色功能不起作用,但我真的不明白为什么。我确定这很愚蠢,也许是混入参数中变量和字符串值的混合?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com