vendredi 11 septembre 2020

Correct syntax for an `@else if` statement in SCSS

I came across a potential bug in a project where a bunch of conditional statements in a .scss file looked as follows...

// Min and max.
                    @else {

                            // Greater than or equal (>= x)
                                @if ($op == 'gte') {
                                    $media: 'screen and (min-width: ' + $x + ')';
                                }

                            // Less than or equal (<= y)
                                @elseif  ($op == 'lte') {
                                    $media: 'screen and (max-width: ' + $y + ')';
                                }

                            // Greater than (> y)
                                @elseif  ($op == 'gt') {
                                    $media: 'screen and (min-width: ' + ($y + 1) + ')';
                                }

Is it possible to write @else if statements like this - @elseif - and for the compiler not to throw any errors?

Aucun commentaire:

Enregistrer un commentaire