Skip to content

Instantly share code, notes, and snippets.

@blackfalcon
Last active December 10, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackfalcon/4513280 to your computer and use it in GitHub Desktop.
Save blackfalcon/4513280 to your computer and use it in GitHub Desktop.
Functions and control directives

Fact: Mixins/functions may not be defined within control directives or other mixins.

Here is an best practice example for passing a value from a mixin into a function for the return

Sass

SassMeister-input.scss

CSS

SassMeister-output.css

See SassMeister Gist

// Sass v3.2.3
$font-size: 16;
@function em($target, $context: $font_size) {
@return ($target / $context) * 1em;
}
@mixin foo($target) {
font-size: em($target);
}
block {
@include foo(12);
}
block {
font-size: 0.75em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment