Reputation: 14988
I was wondering whether there is a certain way to use variables that affect the style in SCSS.
I'm looking for something like:
var x = 1
.class1 {
if (x==1) {
background-color: red;
} else {
background-color: blue;
}
}
.class2 {
if (x==1) {
background-color: blue;
} else {
background-color: red;
}
}
Upvotes: 0
Views: 106
Reputation: 12176
You can use @if and @else
$x:1;
.class1 {
@if $x == 1 {
background-color: red;
} @else {
background-color: blue;
}
}
.class2 {
@if $x == 1 {
background-color: blue;
} @else {
background-color: red;
}
}
Upvotes: 2