Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZeller Ash
Front End Web Development Techdegree Student 6,361 PointsNot sure where I went wrong with this @each loop.
Going through the challenge and came up with this:
@each $color in red, blue, green {
.red_box.#{$color} {
background: red;
}
.blue_box.#{$color} {
background: blue;
}
.green_bow.#{$color} {
background: green;
}
}
Not sure where I went wrong, but it's saying I didn't set up the loop correctly.
1 Answer
Colin Bell
29,679 PointsYou want to use the $color
in both the name and the background property.
@each $color in red, blue, green {
.#{$color}_box {
background-color: $color;
}
}
That way, if you wanted to add more colors you would just need to add one to the list without touching the inside of the each function at all.
Zeller Ash
Front End Web Development Techdegree Student 6,361 PointsZeller Ash
Front End Web Development Techdegree Student 6,361 PointsThanks!