Suppose I want to define a global value for a variable, and then override it for specific selectors. According to the SASS documentation, this should be possible.
Variables are only available within the nested selector level where they are defined. If theyre defined outside of any nested selectors, they are available everywhere.
Logic would then state that โgreenโ and โredโ, since the values โโfor $text-color would only be available within their respective nested selectors, and that $text-color would take on a value of โblueโ when called elsewhere, for example like inside .foo .
$text-color: blue; .green { $text-color: green; color: $text-color; } .red { $text-color: red; color: $text-color; } .foo { color: $text-color; }
However, this is not the case, and the above SASS compiles:
.green { color: green; } .red { color: red; } .foo { color: red; }
Any help in understanding this would be helpful.
Chris brauckmuller
source share