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

CSS Sass Basics (retired) Speeding up Workflow with Sass Sass Functions

Function understand?

Why he is calling function for width pxify(blue($color) instead pxify (blue) ?

Why the $color variable is used as argument?

1 Answer

Tim Knight
Tim Knight
28,888 Points

Saban,

In this example the instructor is using the red(), green(), and blue() functions to get the percentage of those colors found within the variable being passed in. He's not using it to output a color, but instead to output the width to show a visual representation of the percentage of each primary color in the variable $color.

Current time of video where he starts to explain functions is 05:00.

He want to set width via function. That is ok for me. But it isnt clear how he defined function RED? He puts width: red($color). Where red function is defined?

Tim Knight
Tim Knight
28,888 Points

Saban,

This is actually a built in function for Sass. There are several function that Sass has built into the language, see: http://sass-lang.com/documentation/Sass/Script/Functions.html for more details.

Great. In one moment, i thought i miss something in video :) crazy.

Thnx man.