简体   繁体   English

在sass / scss中使变量的乘积

[英]Make product of variable in sass/scss

I need to make a product between two variable in sass/scss. 我需要在sass / scss中的两个变量之间制作产品。 But when I see the compiled file I see that: 但是,当我看到编译的文件时,我会看到:

h1 {
    font-size: 2em * 1em;
  }

This is the code that generate it: 这是生成它的代码:

$h1: 2em;
@mixin setHeadingFont($smartphonePortraitFontSize:1em) {
    h1 {
        font-size: #{($h1 * #{$smartphonePortraitFontSize})};
    }

@include setHeadingFont();

I have also tried: 我也尝试过:

font-size: #{(#{$h1} * #{$smartphonePortraitFontSize})};

or 要么

font-size: #{($h1 * $smartphonePortraitFontSize)};

or 要么

font-size: $h1 * $smartphonePortraitFontSize;

or 要么

font-size: #{$h1} * #{$smartphonePortraitFontSize};

how can I solve it? 我该如何解决?

Thanks 谢谢

I have find the question if someone are interested to it: 我发现有人是否对此感兴趣的问题:

@function removeUnit($num) {
    @return ($num / ($num * 0 + 1));
}

@function getUnit($num){
    @return (unit($num));
}

$unit_num: getUnit($smartphonePortraitFontSize);
h1 {
     font-size: (removeUnit($h1) * removeUnit($smartphonePortraitFontSize))#{$unit_num};
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM