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 trialNeslee Rodillo
19,615 Pointshelp, do not understand the error message
challenge: 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.
My answer:
$color: black;
@mixin square ($size, $color){
height: $size;
width: $size;
border: 1px solid $color;
}
.box {
@include square($color: red, $size: 10px);
}
$colors: blue;
@mixin rainbow ($colors....) {
@each $colors in $colors {
.#($colors) {background-color:$colors;}
}
}
Error: Bummer! You should use the value in $color as the name of a new class within the mixin
3 Answers
John Weland
42,478 PointsThis one was a bear for me to get as well
try this
@mixin rainbow($colors...) {
@each $color in $colors {
.#{$color} {
background: $color;
}
}
}
remember your calling a single color in colors
Neslee Rodillo
19,615 Pointsomg, thank you John!!!!!! I was going around in circles.
Sass is complicated :S
John Weland
42,478 PointsNo worries I did the same thing on this course, its just one of those things you have to remembers singulars and plurals. Sass is complicated and I will likely redo the entire course just to get a better grasp on it, because while complicated Sass and LESS both have exponential power when handling CSS. In my opinion CSS should have been more logic oriented from the start. Maybe in CSS 4 and beyond we'll see some of this.
Neslee Rodillo
19,615 Pointsomg, thank you John!!!!!! I was going around in circles.
Sass is complicated :S