Sass - @if Directive



Description

The @if directive is used to selectively execute the code statements based on the result of evaluating an expression. The @if statements can be followed by several @else if statements. Let us study them from the table given below −

S. No. Types & Description
1 @if

It accepts SassScript expressions and uses the nested styles whenever the result of the expression is anything other than false or null.

2 @else if

It is used with the @if directive, whenever the @if statement fails then the @else if statements are tried and if they also fails then the @else is executed.

sass_control_directives_expressions.htm
Advertisements