Sass 互动版

三目运算判断

三目运算符的语法为:

  • @if($condition, $condition_true, $condition_false),
  • 三个参数分别表示:条件,条件为真的值,条件为假的值。

例如:

$fontBold: true;
p {
    font-weight: if($fontBold, bold, normal);
}

编译生成:

p {
    font-weight: bold;}