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 trialandrewg
7,157 Pointsstuck on final sass challenge :(
Nothing I do is right and I've, unfortunately, spent a good portion of my day trying to figure out this ONE QUESTION. I really don't know why this isn't working, tbh. What's really frustrating about this is that I got through the other 5 questions without a problem, then I get to what SHOULD be the easiest one and I can't figure it out to save my life. Like, are you kidding me?? It's maddening! I have tried everything.
The question says "Use the mixin we just wrote to create a series of classes for the colors: red, orange, yellow, and green."
Voila! I did that! Except APPARENTLY I didn't.... can someone please help me understand what I am doing wrong/what I am not getting here?
<!DOCTYPE html>
<html>
<head>
<title>Sass Basics - Code Challenge</title>
<link rel="stylesheet" type="text/css" href="page-style.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="box"></div>
<div class="red"></div>
<div class="orange"></div>
<div class="yellow"></div>
<div class="green"></div>
</body>
</html>
/* Write your SCSS code below. */
@mixin square ($size, $color: black) {
border: 1px solid $color;
height: $size;
width: $size;
}
.box {
@include square ($color: red, $size: 10px);
}
@mixin rainbow ($colors...) {
@each $color in $colors {
.#{$color} {
background: url ("images/#{$color}/#{$colors}.jpg")
}
}
}
.#{$color}{
@include rainbow(red, orange, yellow, green);
}
2 Answers
Wayne Priestley
19,579 PointsHi Andrew,
You have it, this is all you need.
Remove this.
.#{$color}{
Just use
@include rainbow(red, blue, green, yellow);
Hope this helps.
shezazr
8,275 Pointswhy are you creating a rainbow mixin?
surely it will be something like create a one mixin that takes in an arguement and then uses that to set the color to that..
then the q says use this mixn to create CLASSES.. so not a rainbow.. but different classes
.red { mixin(red) // or however you call a mixin }
andrewg
7,157 Pointsyeah, um... i dont think thats gonna work....
Im not trying to create a rainbow mixin. Im trying to create an @include function which requires a name.. What else would I call it other than the name of the mixin. Hence, rainbow.
the previous questions had me title the mixin "rainbow". maybe thats what youre confused about
Wayne Priestley
19,579 PointsWayne Priestley
19,579 PointsI was wondering why you have a background url
background: url ("images/#{$color}/#{$colors}.jpg")
And not
background: $color;
andrewg
7,157 Pointsandrewg
7,157 PointsI don't know why either. I guess I'm just very confused. But your solution really helped me on this one and I'm very grateful. Thank you.