SASS 百分比

SASS percentage

SOF 的小伙伴们大家好:)

是否有机会使用 Sass(我的意思是 output.css 文件中的最终结果)得到这个数学示例的结果:

1000 - 20% = 800

例如,如果我尝试这样的事情:

$people: 1000
$dumb_by_trump: percentage(0.2)
$total_adequate: $people - $dumb_by_trump

us poll
    hello_world: $total_adequate

然后我会在我的 output.css 文件中看到结果为:

us poll {
hello_world: 980%; }

但我们需要看到结果为“800”。可能吗?谢谢

将百分比乘以您的常数值

$people: 1000
$dumb_by_trump: percentage(0.2)
$total_adequate: $people - $people*($dumb_by_trump/100%)

us pool
    hello_world: $total_adequate

结果

us pool {
  hello_world: 800;
}