2

如何将 SASS 中的两个变量组合成一个单元?设置如下:

$font-size: 16;
$font-unit: px;

$base-font-size: {$font-size}{$font-unit} !default;

@if unit($base-font-size) != 'px' { @warn "Parameter must resolve to a value in pixel units."; }

这会引发编译错误:Invalid CSS after ... expected expression ... was

谢谢您的帮助!

4

1 回答 1

3

试试这个:

$font-size: 16;
$font-unit: 1px;

$base-font-size: $font-size * $font-unit !default;

@if unit($base-font-size) != px { @warn "Parameter must resolve to a value in pixel units."; }
于 2013-02-14T21:41:27.553 回答