📅  最后修改于: 2020-10-20 05:45:00             🧑  作者: Mango
在本章中,我们将研究控制指令和表达式。可以通过使用SassScript支持的控制指令和表达式来完成基于某些条件的样式设置或多次使用相同样式的变体。这些控制指令是主要用于mixin的高级选项。它们是Compass库的一部分,因此需要相当大的灵活性。
下表列出了SASS中使用的控制指令和表达式-
S. No. | Control Directive & Expression with Description |
---|---|
1 | if()
Based on the condition, if() function returns only one result from two possible outcomes. |
2 | @if
The @if directive accepts SassScript expressions and uses the nested styles whenever the result of the expression is anything other than false or null. |
3 | @for
The @for directive allows you to generate styles in a loop. |
4 | @each
In @each directive, a variable is defined which contains the value of each item in a list. |
5 | @while
It takes SassScript expressions and untill the statement evaluates to false it iteratively outputs nested styles. |