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 trialHoward Slatter
8,049 PointsAdvanced Sass Concepts - @each (2 of 2)
Really having a hard time with this:
Use an @each loop to set the variable $color to the color red, then blue, and finally green. Use the loop to create three classes: .red_box, .blue_box, and .green_box. The background color for each class should be set to the corresponding color.
@each $color in red, blue, green {
.#{$color}_box {
background: .#{$color}
}
}
I'm getting "Compilation Error"
3 Answers
Ben Rubin
Courses Plus Student 14,658 PointsTake the . out in background: .#{$color}
Jaime Borschuk
6,112 PointsYou also need a semicolon after #{$color};
Howard Slatter
8,049 PointsThanks Ben, it's always something 'obvious' right in front of my face...
Elijah Collins
19,457 PointsElijah Collins
19,457 PointsJust to make this clear for anyone in the future