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 trial

CSS

Vince Brown
Vince Brown
16,249 Points

code challenge- Sass @each

I am stuck on the @each loop i believe i got the code right for generating the classes but am not sure about the background-color?

/* Write your SCSS code below. */
@for $i from 1 through 3 {
.item_#{$i}{
  width: $i * 100px;
  }
  }
  @each $color red, blue, green {
    .#{$color}_box {
    background-color: .#{$color};
    }
    }

1 Answer

Hi Vince,

You're missing the keyword in in your @each statement. @each $color in red, blue, green {

Also, when setting the background-color you would use the $color variable directly much like you used the $i directly when you set the width in the code above.

Hope that helps.

Vince Brown
Vince Brown
16,249 Points

Thank you Jason, that worked perfectly