--- title: Use @each to Map Over Items in a List --- # Use @each to Map Over Items in a List --- ## Problem Explanation The @each directive loops over a list and for each iteration the variable is assigned the value in the list. **Example:** ```html
--- ## Solutions
Solution 1 (Click to Show/Hide) ```html
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; } ```