如何将 CSS @property 与 scss 一起使用?

问题描述 投票:0回答:1

我想用特定语法声明一个自定义变量,例如:

@property --colorPrimary {
  syntax: "<color>";
  initial-value: magenta;
  inherits: false;
}

这样我就可以为属性设置动画,但是这段代码似乎被 scss 忽略了。

css sass css-houdini
1个回答
0
投票

快速玩一下https://sass-lang.com/playground,如果有帮助的话我想出了这个。

@mixin property($variable: variable, $syntax: "<number>", $inherits: true, 
$initial-value: 0){
  @property --#{$variable} {
    syntax: $syntax;
    inherits: $inherits;
    initial-value: $initial-value;
  }
}

@include property(colour-primary-hue, "<number>", false, 255)

输出

@property --colour-primary-hue {
  syntax: "<number>";
  inherits: false;
  initial-value: 255;
}
© www.soinside.com 2019 - 2024. All rights reserved.