<div class="darkslateblue"></div>
<div class="mediumorchid"></div>
<div class="seagreen"></div>
<div class="steelblue"></div>
// colors
@colors: darkslateblue mediumorchid seagreen steelblue;
// loop definition
.backgrounds(@list, @i: 1) when (@i <= length(@list)) {
// extract the right color from the list
@color: extract(@list, @i);
// apply the background to the selector
[email protected]{color} {
background: @color;
}
// recursive call for the next color
.backgrounds(@list, @i + 1);
}
// application
.backgrounds(@colors);
// styles
body {
display: flex;
}
div {
flex: 1 1 auto;
height: 100vh;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.