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 Sass Basics (retired) Advanced Sass Concepts Creating Loops with @for and @each

Misty Majewski
Misty Majewski
5,276 Points

@for loops

Make a @for loop to iterate through the numbers 1 through 3. The for loop should create classes named in the format "item_#{$i}" and set the width to be $i * 100px.

@for $i from 1 through 3 {
    .item:nth-child (#{$i}) {
     width: $i * 100px;
     }
     }

I am a little confused. I did it just like he did in the video. I can not figure out what I am missing. Thank you for your help.

1 Answer

Misty Majewski
Misty Majewski
5,276 Points
@for $i from 1 through 3 {
    .item_#{$i} {
    width: $i * 100px;
  }

Found someone with the answer.. Since the video only used nth child I thought it was a necessity to make it work. Finally figured it out!