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 Modular CSS with Sass Sass Grid System Sass Grid System Challenge

What am I missing in this @for and percentage challenge?

@for $i from 1 through $cols { .grid__col--#{$i} { $target : ($width * $i) + ($gutter * ($i -1));
width : percentage($target / $context); } }

It keeps giving me an error: invalid CSS after "width . . . .

I defined $target just like they said to, and calculate the width with the percentage. What am I missing?

Thanks!

style.scss
div {
  background-color: green;
}

$cols    : 10;
$width   : 50px;
$gutter  : 15px;
$context : ($width * $cols) + ($gutter * ($cols - 1));

@for $i from 1 through $cols {
  $target : ($width * $i) + ($gutter * ($i -1));

  .grid__col--#{$i} {
      width   : percentage($target / $context);
  }
}

I finally figured it out. I was missing a space before the one in my $target: equation. That is 30 minutes I will never get back, but I will probably never make that mistake again. :)

1 Answer

I finally figured it out. I was missing a space before the 1.

Andrew Hawes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andrew Hawes
Python Web Development Techdegree Graduate 28,105 Points

I just found this wondering if the challenge was bugged or something. Somehow, I had the exact same problem. I had -1 instead of - 1. Not sure how I missed that or why I did that.