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 Modular CSS with Sass Getting Modular with Mixins and Functions Background Image Mixin

em Values in mixins

I thought it was better to use em values for responsive design? Can em values be passed to a mixin instead of px?

2 Answers

Patrik Horváth
Patrik Horváth
11,110 Points

yup i personaly use only REMs :) for example SET website ROOT to 10px; and 1 REM = 10px; easyest calculates :)

7.8 rem = 78px :)

work with Sass too :)

Thanks Patrik Horváth , are we able to pass em to a mixin?

Patrik Horváth
Patrik Horváth
11,110 Points

yea you can use any CSS in Sass and EM/ REM / PX / VH / % ... are lenght values for CSS and SASS is just something that help you write FAST CSS so it means you can use same things as in CSS also in MIXIN because MIXIN is just variable where you can store a lot of CSS lines :)

Greg Kaleka
Greg Kaleka
39,021 Points

Jaycode, here's some additional info on REMs. Just so you're aware that they are based on the "base" font size (which is not always 10px).

My appologies everyone for any confusion. In re-reading my initial question, what I meant to ask is if we can use the famous em(target / context) function that Guil taught us in previous lessons as a parameter.

@function em($target, $context: $base__font-size) {
    @return ($target / $context) * 1em;
}

Is it possible to use a sass function as a parameter?