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

Final Sass Exercises

I am painfully stuck on the last part of the Sass course with the @each loops. For the love of god someone help! Can anyone just post the answer so I can see how it works? I have no idea what I'm doing wrong.

Here's my code (it's incomplete because I gave up):

@for $i from 1 through 3 {
    .item_#{$i} {
    width: $i * 100px;
  }
}

@each $color in red, blue, green {
    .red_box.#{$color} {
    background-color: #{$color};
  }
}
James Barnett
James Barnett
39,199 Points

> Can anyone just post the answer so I can see how it works?

Treehouse is kinda like a book with videos instead of text and code challenges instead of exercises. So you can skip around just like you do in a book.

However, learning to program is kinda like learning algebra, each piece builds on the last one. If you move on without fully understanding it, it might come back to bite you. YMMV.

Post a link to the question Derick Moncado and I would be happy to explain it to you. Rather than just critique your post.

Thanks

2 Answers

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

It took me a few hours to complete this exersise. Quite difficult stuff.

The Javascript foundations and intermediate courses can help you get further. At this point of the exercise Sass becomes more like coding instead of designing. So programming skills help a lot.

James Barnett
James Barnett
39,199 Points

> At this point of the exercise Sass becomes more like coding instead of designing. So programming skills help a lot.

That's really great advice :+1:

Just looked at your code on question 2 and if you look at the question it wants class named .color_box atm your input of

@each $color in red, blue, green {
     .red_box.#{$color} { // This is the line you need to look at
      background-color: #{$color};
  }
}

will output

.red_box.red .red_box.blue .red_box.green

Check out the line i commented and re-work it to fulfill the goal in the question.7

your output need to be

.red_box .blue_box .green_box

If still unsure tag me with the @ and my name