有没有办法让 calc 函数与 Sass 中的 * 运算符一起工作?
Is there a way to make the calc function work with the * operator in Sass?
我正在尝试设置默认字体大小,然后使用它来获取其他一些字体大小。
$base-font-size: calc(100% + 0.25vw); // this is fine
$font-size--2: $base-font-size * 0.5; // the multiplication causes an error here
$font-size--1: $base-font-size * 0.75;
$font-size-1: $base-font-size * 1.25;
我从编译器那里得到这个
错误:未定义的运算“calc(100% + 0.25vw) * 0.5”。
╷
14 │ $font-size--2: $base-font-size * 0.5;
│ ^^^^^^^^^^^^^^^^^^^^^^
╵
styles.scss 14:16 根样式表
进程已完成,退出代码为 65
您必须执行以下操作:
$base-font-size: calc(100% + 0.25vw);
$font-size--2: calc(#{$base-font-size} * 0.5);
$font-size--1: calc(#{$base-font-size} * 0.75);
$font-size-1: calc(#{$base-font-size} * 1.25);
我正在尝试设置默认字体大小,然后使用它来获取其他一些字体大小。
$base-font-size: calc(100% + 0.25vw); // this is fine
$font-size--2: $base-font-size * 0.5; // the multiplication causes an error here
$font-size--1: $base-font-size * 0.75;
$font-size-1: $base-font-size * 1.25;
我从编译器那里得到这个
错误:未定义的运算“calc(100% + 0.25vw) * 0.5”。 ╷ 14 │ $font-size--2: $base-font-size * 0.5; │ ^^^^^^^^^^^^^^^^^^^^^^ ╵ styles.scss 14:16 根样式表
进程已完成,退出代码为 65
您必须执行以下操作:
$base-font-size: calc(100% + 0.25vw);
$font-size--2: calc(#{$base-font-size} * 0.5);
$font-size--1: calc(#{$base-font-size} * 0.75);
$font-size-1: calc(#{$base-font-size} * 1.25);