Answer the question
In order to leave comments, you need to log in
How to write a SCSS function to change background-color from line to line?
There is a table:
<table>
<tr>
<td>red</td>
</tr>
<tr>
<td>orange</td>
</tr>
<tr>
<td>yellow</td>
</tr>
<tr>
<td>green</td>
</tr>
<tr>
<td>blue</td>
</tr>
<tr>
<td>indigo</td>
</tr>
<tr>
<td>violet</td>
</tr>
</table>
background-color
corresponding color of the rainbow. background-color
for each row looks like this:tr {
&:first-child {
background-color: adjust-hue($bg-base, 0deg);
}
&:nth-child(2) {
background-color: adjust-hue($bg-base, 30deg);
}
&:nth-child(3) {
background-color: adjust-hue($bg-base, 60deg);
}
&:nth-child(4) {
background-color: adjust-hue($bg-base, 120deg);
}
&:nth-child(5) {
background-color: adjust-hue($bg-base, 180deg);
}
&:nth-child(6) {
background-color: adjust-hue($bg-base, 240deg);
}
&:nth-child(7) {
background-color: adjust-hue($bg-base, 300deg);
}
}
background-color
for each row via SCSS function? Thanks in advance. Answer the question
In order to leave comments, you need to log in
@for $i from 1 through 7{
tr{
&:nth-child(#{$i}) {
@if($i <= 2) {
background-color: adjust-hue($bg-base, (30 * ($i - 1)));
} @else {
background-color: adjust-hue($bg-base, (60 * ($i - 2)));
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question