Sass is returning a list of negative numbers instead of subtracting them

前端 未结 2 875
长情又很酷
长情又很酷 2020-12-12 04:02

I\'m trying to do math operation with lengths:

$itemWidth: 25px;
$item2Width: 80px;

element {
    width: $itemWidth/2-$item2Width/2-5px
}

2条回答
  •  庸人自扰
    2020-12-12 04:43

    Wrap the calculation in parentheses. This tells SASS that the whole thing is part of a calculation.

    $itemWidth: 25px;
    $item2Width: 80px;
    
    element {
        width: ($itemWidth/2-$item2Width/2-5px);
    }
    

提交回复
热议问题