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 trialAbdullahi Abdinasir Ali
9,520 PointsHow do in mixin square and specify the argument each variable
Where am getting wrong
@mixin square ($size , $color: black ){
height: $size;
width: $size;
border: 1px solid $color;
}
.box{
@include square($size: 50px ,$color: red);
height: $size;
width: $size;
border: $color;
}
2 Answers
Liam Ferb
8,454 PointsOkay, so what mixins do is essentially (when compiling) replaces the @include ____ with the code you placed in the mixin, and replaces the variables with the arguments passed in, in other words, mixins don't set the variables, so you can get rid of the properties below @include, or in other words, you should have this:
@mixin square ($size, $color: black) {
height: $size;
width: $size;
border: 1px solid $color;
}
.box {
@include square(50px, red);
}
Oh and you don't have to specify the variable names unless you are placing them in another order than they appear in the parentheses next to the mixins.
Hope this helps!
trio-group I.AM
25,713 PointsCan you explain what exactly you're having problems with? The way you would use this mixin is the following:
.box { @include square(50px, red); }
Abdullahi Abdinasir Ali
9,520 PointsAm have box class which asked include square mixin and specify variable which am getting a lot problem with
Abdullahi Abdinasir Ali
9,520 PointsAbdullahi Abdinasir Ali
9,520 PointsWonderful explanation I really appreciate it. Thanks