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


6,232 Points

Mixins stage 2

Hey all, having a hard time understanding this question. It seems dead easy but I don't know what its asking! "Write a new definition for the "button" mixin, which takes two arguments: $color and $size. The background should be set using the value in the $color variable, and the width should be set using the $size variable. The height should be half of the value in the $size variable."

This is what I've got

@mixin button { $color: #000; $size: 100px; background:$color; width: $size; height: $size / 2; }

.menu_button { @include button; }

Am I close???

3 Answers

Courses Plus Student 9,364 Points


The first part of the question should help... "Write a new definition for the "button" mixin, which takes two arguments: $color and $size". The mixin you have created does not take any arguments.

E.g. @mixin button($color, $size) { //rest of code here...}

Hope this helps.

Here you go.

@mixin button ($color,$size)

@include button(#369,50px)

Button signifies the color and size. Notice that background =$color and width and height=$size below the button. So color and size are being read as those css properties. Hope this helps.

Piccia Neri
Piccia Neri
8,937 Points

I agree that this question is really badly phrased. I think I really understood this bit, but it's very difficult to work out what you are being asked to do.