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 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,863 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,863 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.