📅  最后修改于: 2020-12-25 04:03:22             🧑  作者: Mango
Sass控制指令和表达式可帮助您根据某些条件使用样式。它还使您能够多次应用相同的样式。 SassScript支持它。
控制指令是指南针库的一部分。这些主要用于mixin,并要求相当大的灵活性。
Sass中使用的控制指令和表达式的列表:
Index | Expression | Description |
---|---|---|
1. | if() function | The if() function is based on the condition. It returns only one result from two possible values. |
2. | @if directive | 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. | @else if directive | The Sass @else-if directive is used when @if directive is failed. If it is failed @else directive is used. |
4. | @for directive with through keyword | The @for directive facilitates you to generate styles in a loop. |
5. | @each directive | A variable is defined within the @each directive which contains the value of each item in a list. |
6. | @each directive with multiple assignments | We can use Sass @each directive with multiple values like $var1, $var2, $var3, … in . |
7. | @for directive with to keyword | In Sass @for directive, the “to” keyword is used to specify the range form value to the value before value. |
8. | @while directive | It takes SassScript expressions and until the statement evaluates to false it iteratively outputs nested styles. |