Answer the question
In order to leave comments, you need to log in
How to combine map keys into a ruleset in SCSS?
Hello, I have a map with data like this:
$rank: (
[8, 7]: red,
[6, 5]: blue,
[4, 3]: green,
[2, 1]: black,
);
.rank--8, .rank--7 {
color: red;
}
.rank--6, .rank--5 {
color: blue;
}
.rank--4, .rank--3 {
color: green;
}
.rank--2, .rank--1 {
color: black;
}
.rank {
@each $level, $color in $rank{
@each $level_val in $level {
&--#{$level_val} {
color: $color;
}
}
}
}
.rank--8 {
color: red;
}
.rank--7 {
color: red;
}
.rank--6 {
color: blue;
}
.rank--5 {
color: blue;
}
.rank--4 {
color: green;
}
.rank--3 {
color: green;
}
.rank--2 {
color: black;
}
.rank--1 {
color: black;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question