Files

47 lines
617 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Use @each to Map Over Items in a List
---
## Use @each to Map Over Items in a List
## Solution
2018-10-12 15:37:13 -04:00
```sass
<style type='text/sass'>
@each $color in blue, black, red {
.#{$color}-bg {background-color: $color;}
}
div {
height: 200px;
width: 200px;
}
</style>
2018-10-12 15:37:13 -04:00
<div class="blue-bg"></div>
<div class="black-bg"></div>
<div class="red-bg"></div>
```
The solution above will generate the following CSS:
```css
.blue-bg {
background-color: blue;
}
.black-bg {
background-color: black;
}
.red-bg {
background-color: red;
}
div {
height: 200px;
width: 200px;
}
```