Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

williamrossi
williamrossi
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

andrewvernon
PLUS
andrewvernon
Courses Plus Student 9,364 Points

Hi,

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)
{
background:$color;
width:$size;
height:$size/2;
}

.menu_button{
@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.