首页 文章

搞清楚sass mixins

提问于
浏览
0

我是sass的新手,我试图让我的脑袋缠绕在mixins上并在mixins中使用if / else语句 . 我试着写一些简单的东西,基本上说如果选择器的宽度设置大于50%它将是某种颜色,否则它将是不同的颜色 .

这是我到目前为止的代码:

@mixin color-class($width) {
  @if "$width > 50%" {
    background-color: purple;

  } @else {
      background-color: orange; 
    }
}

.selector-two {
  @include color-class(40%);
}

.selector-three {
  @include color-class(80%);
}

无论我放在什么 Value ,css都会将颜色输出为紫色所以我肯定会遗漏一些东西,任何帮助都会非常感激 .

1 回答

  • 0

    尝试删除 "

    @if $width > 50% {}
    

    你可以在这里快速试验:http://sassmeister.com/

相关问题