【问题标题】:Is there a way to make the calc function work with the * operator in Sass?有没有办法让 calc 函数与 Sass 中的 * 运算符一起工作?
【发布时间】:2020-12-07 02:57:47
【问题描述】:

我正在尝试设置默认字体大小,然后使用它来获取其他字体大小。

$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 结束

【问题讨论】:

    标签: css sass fonts css-calc


    【解决方案1】:

    您必须执行以下操作:

    $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);
    

    【讨论】:

    • 是的,对不起,我是新来的。
    猜你喜欢
    • 2020-03-09
    • 1970-01-01
    • 2019-10-18
    • 2013-03-27
    • 2010-09-12
    • 1970-01-01
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多