【发布时间】:2014-04-09 19:03:02
【问题描述】:
我是 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%);
}
无论我在这里输入什么值,css 都会将颜色输出为紫色,所以我肯定遗漏了一些东西,任何帮助将不胜感激。
【问题讨论】:
标签: if-statement sass mixins