Sass - Control Directives & Expressions
In this chapter, we will study about Control Directives & Expressions. Styling based on some conditions or applying the same style many times with variations can be accomplished by using control directives and expressions, which are supported by SassScript. These control directives are advanced options used mainly in mixins. They require considerable flexibility, as they are a part of Compass libraries.
The following table lists the control directives and expressions used in SASS −
|S. No.||Control Directive & Expression with Description|
Based on the condition, if() function returns only one result from two possible outcomes.
The @if directive accepts SassScript expressions and uses the nested styles whenever the result of the expression is anything other than false or null.
The @for directive allows you to generate styles in a loop.
In @each directive, a variable is defined which contains the value of each item in a list.
It takes SassScript expressions and untill the statement evaluates to false it iteratively outputs nested styles.