1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Using Maps In SCSS as a css til

This commit is contained in:
jbranchaud
2019-08-09 14:38:35 -05:00
parent d573ec4f11
commit 6c15261dac
2 changed files with 34 additions and 1 deletions

32
css/using-maps-in-scss.md Normal file
View File

@@ -0,0 +1,32 @@
# Using Maps In SCSS
You can collect a set of like values into a
[map](https://sass-lang.com/documentation/values/maps) with the following SCSS
syntax:
```scss
$backgrounds: (
"gray": #AAAAAA,
"red": #FF4136,
"blue": #0074D9,
);
```
You can then access a value from the map using the [`map-get`
function](https://sass-lang.com/documentation/values/maps#look-up-a-value):
```scss
.boxA {
background-color: map-get($backgrounds, "gray");
}
.boxB {
background-color: map-get($backgrounds, "red");
}
.boxC {
background-color: map-get($backgrounds, "blue");
}
```
See a [live example here](https://codepen.io/jbranchaud/pen/WVJrgp).