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 trialChristina P
4,048 PointsStuck on Sass Challenge
Stuck on this challenge: 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.
My answer:
@for $i from 1 through 3 { .item_#{$i} { width: $i * 100px; } };
@each $color for red, blue, green{ .#{$color}_box{ background: $color;} }
The program says that adding this makes my first task wrong, but I can't seem to fix it. Help please..
2 Answers
Wayne Priestley
19,579 PointsHi Christina,
You almost there,
@each $color in red, blue, green{
.#{$color}_box{
background-color:$color;
}
}
James Whiting
39,124 PointsClearer
@each $color in red, blue, green{ .#{$color}_box{ background-color: #{$color}; } }