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 trialpablo boerr
1,331 PointsSass Final Exercise question 6 of 6
For some reason, I can't get the final exercise, I've tried several solutions, but I keep on getting an error
the question is Use the mixin we just wrote to create a series of classes for the colors: red, orange, yellow, and green.
@mixin rainbow($colors...){
@each $color in $colors{
.#{$color}{
background:$colors;
}
}
}
26 Answers
Tom Bedford
15,645 PointsI think there's just one mistake now in your rainbow mixin. Check where you are declaring the background color.
hint: $colors outputs every color not just one.
//rainbow
@mixin rainbow($colors...){
@each $color in $colors{
.#{$color} {
background: $colors; /* this line */
}
}
}
Pawel Wronski
8,872 Points@mixin square($size, $color: black)
{ height: $size; width: $size; border: 1px solid $color; }
.box { @include square($color: red, $size: 10px) }
@mixin rainbow($colors...){
@each $color in $colors{
.#{$color} {
background: $colors;
}
}
}
@include rainbow(red);
@include rainbow(orange);
@include rainbow(yellow);
@include rainbow(green);
i think it is a but in excercise.
mark kling
5,504 PointsI used your top part for task 5....thanks!
Tom Bedford
15,645 PointsHave you included the mixin?
"Use the mixin we just wrote to create a series of classes for the colors: red, orange, yellow, and green."
@include rainbow (......etc);
Tom Bedford
15,645 PointsHave you tried running this in your own text editor outside of the challenge? Currently it doesn't output anything in the .css file as the whole thing is still inside the original curly brackets forming the mixin. I have put some notes in the code to help guide you as there are a few mistakes here.
I would recommend playing around with it outside of the code challenge until you get it to compile to the desired results as it will be quicker than running the preview there over and over.
//rainbow
@mixin rainbow($colors...) { /* this curly bracket closes all the way at the bottom, is that correct? */
@each $color in $colors {
.#{$color} {
background: $colors; /* $colors is the whole group not just one */
}
}
.#{$color} { /*do you need this line again? */
@include rainbow(red, orange, yellow, green); /* this line should be on it's own outside of the mixin, check your curly brackets, you are still inside the mixin declaration */
}
} /* end of the very first curly bracket */
Tom Bedford
15,645 PointsCould you post the full code you are using to answer the question?
pablo boerr
1,331 PointsHere's everything I have in the code editor
/* Write your SCSS code below. */ @mixin square($size, $color:black) { height:$size; width:$size; border:1px solid $color; }
//rainbow @mixin rainbow($colors...){ @each $color in $colors{ .#{$color}{ background:$colors; } } }
.box{ @include square($color:red, $size:10px); }
@include rainbow(red, orange, yellow, green);
Tim Ruby
Courses Plus Student 19,038 PointsAny chance you can share in what your solution was Pablo? I am stuck on the same section and it is driving me insane!
Tim Ruby
Courses Plus Student 19,038 PointsIt's all good my friend. I'm still curious as to what your solution was? I ended up@including each color and it finally passed. Not sure if that is the correct way or not but it works.
Felipe Felix
4,789 PointsPlease post the full code!i can't get this hell thing right...It's been tow days I'm trying to solve this question.Help!
Thanks :)
Antonio Rodrigues
2,306 PointsFull code is here:
hope it helps =)
/* Write your SCSS code below. */
@mixin square($size, $color: black) {
height: $size;
width: $size;
border: 1px solid $color;
}
@mixin rainbow($colors...) {
@each $color in $colors {
.#{$color} {
background: $color;
}
}
}
@include rainbow(red, orange, yellow, green);
.box {
@include square($color: red, $size: 10px);
}
pablo boerr
1,331 PointsHi Tom, thanks for the quick reply.
Yes I have included it.
I've tried several solution, I'm sure it's right there in front of me.
pablo boerr
1,331 PointsSafari just crashed, And I have to restart all the exercises for the 6th chapter. It's currently past 4Am over here.
I'll post them again when I get to the 6th question. For now I go to bed and catch up on some sleep.
Thanks again for taking the time Tom.
Tom Bedford
15,645 PointsGo get some sleep!
pablo boerr
1,331 PointsHere's the last version I tried
//rainbow @mixin rainbow($colors...){ @each $color in $colors{ .#{$color}{ background:$colors; } } .#{$color}{ @include rainbow(red, orange, yellow, green); } }
pablo boerr
1,331 PointsIn my code editor the output I get is .box{height:10px;width:10px;border:1px solid red} .red,orange,#ff0,green{background:red,orange,#ff0,green} .red,orange,#ff0,green{background:red,orange,#ff0,green} .red,orange,#ff0,green{background:red,orange,#ff0,green} .red,orange,#ff0,green{background:red,orange,#ff0,green}
pablo boerr
1,331 PointsFinally got it. Thanks Tom.
I really appreciate the help.
Tim Ruby
Courses Plus Student 19,038 PointsFigured it out! Woohoo!
pablo boerr
1,331 PointsHey Tim, Just got your message, glad you figured it out man.
Ginelle Sutherland
12,807 PointsHelp with this please: Use the mixin we just wrote to create a series of classes for the colors: red, orange, yellow, and green
Tiago Pinheiro
10,622 PointsStuck here too! Please help!
Tiago Pinheiro
10,622 PointsStuck here too! Please help!
mansoor ali
5,662 Pointstask 6 of 6 stage 4 i am struck please give me the correct code for this task @mixin square ($size, $color: black) { height: $size; width: $size; border: 1px solid $color; } @mixin rainbow($colors: red,orange,yellow,green); { @each $color in $colors { .#{$color} { background: $colors; } }
.#{$color} { @include rainbow(red, orange, yellow, green); }
.box { @include square($color: red,$size: 10px); }
Pawel Wronski
8,872 Pointsyes i think it is a bug
mark kling
5,504 Pointsjust make 4 individual @includes and it will get 'er done! Thanks to Pawel for sharing!
Elizabeth BABYCH
6,993 PointsI hope this helps, this worked for me after a while (this is just the rainbow mixin part):
@mixin rainbow($colors...) { @each $color in $colors { .#{$color} { background: $color; } } }
@include rainbow(red, orange, yellow, green);
(for me, I had put down: @each $color in $colors { .colors.#{$color}{background.$color;} but this is wrong because my classes were listed as .color.red, etc.. instead of .red, .orange etc...)
Hope this helps!
Bhanu Prakash moturu
4,259 Pointswhy is passing of arguments in list type not working i am confused is it a bug ?
@include rainbow(red orange yellow green);