What Sass variable scopes do you know and what are the differences between them?

Experience Level: Junior
Tags: Sass

Answer

Sass has two variable scopes. Global scope and local scope.

  • Global scope variables can be declared outside of a function and a mixin
  • Local scope variables are declared inside of blocks (between curly braces)
$color1: lime;

@mixin box($width, $height) {
  $color2 : blue;
  height: $height;
  width: $width;
  border: solid 1px $color2;
  background: lime;
}

.rectangle {
  @include box(30px, 80px);
}

Comments

No Comments Yet.
Be the first to tell us what you think.
Sass for beginners
Sass for beginners

Are you learning Sass ? Try our test we designed to help you progress faster.

Test yourself

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

Anonymous
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
Anonymous
e
Anonymous
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e