vendredi 6 novembre 2015

How can I have @if inside the value of a CSS property?

Is there a way to use Sass’ @if statement inside the value part of a property? I.e. make the following code work:

@mixin color-transition($color:true, $background:true, $border:true, $duration: 0.2s) {
    transition: 
        @if ($color) {
            color $duration linear,
        }
        @if ($background) {
            background-color $duration linear,
        }
        @if ($border) {
            border-color $duration linear,
        }
    ;
}

I can’t move transition: inside of the if clause because in that case the last of them would overwirte the former …

Aucun commentaire:

Enregistrer un commentaire