Skip to content

Instantly share code, notes, and snippets.

@DannyJoris
Created January 17, 2015 04:22
Show Gist options
  • Save DannyJoris/24cdc483103c952aaeb4 to your computer and use it in GitHub Desktop.
Save DannyJoris/24cdc483103c952aaeb4 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
// Initialize a global variable at root level.
// In this case, the `!global` flag is optional.
$variable: 'initial value' !global;
// Create a mixin that overrides that global variable.
@mixin global-variable-overriding {
$variable: 'mixin value' !global;
}
.local-scope::before {
// Create a local variable that shadows the global one.
$variable: 'local value';
// Include the mixin: it overrides the global variable.
@include global-variable-overriding;
// Print the variable's value.
// It is the **local** one, since it shadows the global one.
content: $variable;
}
// Print the variable in another selector that does no shadowing.
// It is the **global** one, as expected.
.other-local-scope::before {
content: $variable;
}
.local-scope::before {
content: "local value";
}
.other-local-scope::before {
content: "mixin value";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment