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 Advanced Mixin Arguments

Vince Brown
Vince Brown
16,249 Points

Final Code Challenge Sass

Design a mixin (called "rainbow") that can take any number of colors via the argument $colors.... Within the mixin, use the loop @each $color in $colors to create a class named after each color, and set its background to the corresponding color.

I keep getting compilation error, i believe i got proper syntax as far up to setting the class name? but i cant get background to push through

  @mixin rainbow($colors...) {
    @each $color in $colors {
        .#{$color}{
        background: $color;
            }
        }

1 Answer

Thomas Daugherty
Thomas Daugherty
23,983 Points

The only thing I see is that it's missing a closing tag for the mixin.

@mixin rainbow($colors...) {
    @each $color in $colors {
        .#{$color} {
            background: $color;
        }
    }
} /* <-- End Mixin */
Vince Brown
Vince Brown
16,249 Points

ahhhhhh! of course those damn curly braces thank you thomas i guess i was just staring at the screen too long forgot to check for the simple stuff first.

Vince Brown
Vince Brown
16,249 Points

ahhhhhh! of course those damn curly braces thank you thomas i guess i was just staring at the screen too long forgot to check for the simple stuff first.