Archived video

This video is archived and won't be updated. We're keeping it online for now as a courtesy.

Sass Functions

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:05
    Another Sass feature that is similar to mixins
  • 0:10
    but definitely not the same are functions.
  • 0:12
    And with a function, what you can do is a bunch of processing or calculations
  • 0:17
    and then return a final value that you actually want to use in your CSS.
  • 0:23
    So instead of returning a bunch of lines of CSS,
  • 0:26
    you're just returning a single value at the end of the day.
  • 0:30
    So in this lesson, what we're going to do is kind of compare
  • 0:34
    a mixin and a function side by side
  • 0:36
    so that it's really clear what the differences are between them.
  • 0:39
    And then chances are, if you're using a function, if there's something you need
Loading ...

Sass Functions


Functions are another form super-variable, as it were, where you do a bunch of work that is assigned to something you can print out. But in this case you aren't injecting a bunch of CSS, instead you are just printing out a nice, final value. For many things you will want to do with functions, someone else has probably already written it. Sass comes with a lot of predefined functions for you to use, and there are libraries, like Compass, which provide many more. We'll take a look at some of the functions that Sass provides for us and see a function in action, along with our mixin, side by side, to really see the difference between them.

Additional resources: