【发布时间】:2020-09-28 11:38:04
【问题描述】:
我想使用var(--darkGrey)。到目前为止,我已经尝试过:
$grey: #ddd; // I'd like to remove this line
:root {
--grey: #ddd;
--darkGrey: darken($grey, 55%); // doesn't fail but doesn't work
--darkGrey: darken(#ddd, 55%); // doesn't fail but doesn't work
--darkGrey1: #{darken($grey, 55%)}; // works but I don't like having a Sass var
--darkGrey2: #{darken(var(--grey), 55%)}; // fails: "var(--grey)" is not a color for `darken'
--darkGrey3: #{darken(#ddd, 55%)}; // works but I'd need to use a css var. I have plenty of colors and references
}
【问题讨论】:
-
--darkGrey1: #{darken(#ddd, 55%)};? -
也可以,但我不仅有颜色参考我还有许多其他颜色使用其他变量,所以我不想重复它们中的任何一个。
-
你不能在 SASS 函数中使用 CSS 变量