Sass Map function
Sass Map (mapping) objects are one or more pairs key/value
to show.
Sass Map is immutable, so it is processing Map
object, a new Map
object, not in the original Map
object to make changes.
The following table lists the Sass’s Map
function:
Function |
Description & example |
---|---|
|
Returns the value corresponding to key in Map. If there is no corresponding key, the null value is returned. Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-get ($font-sizes, “small”) result: 12px |
|
Determine whether map has a corresponding key. Return true if it exists, otherwise return false. Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-has-key ($font-sizes, “big”) result: false |
|
Returns a queue of all the key in the map. Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-keys ($font-sizes) result: “small”, “normal,”large” |
|
Merge two map to form a new map type, that is, add map2 to the tail of map1 Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) $font-sizes2: (“x-large”: 30px, “xx-large”: 36px) map-merge ($font-sizes, $font-sizes2) result: “small”: 12px, “normal”: 18px, “large”: 24px, “x-large”: 30px, “xx-large”: 36px |
|
Remove keys from map, and multiple key are separated by commas. Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-remove ($font-sizes, “small”) result: (“normal”: 18px, “large”: 24px) map-remove ($font-sizes, “small”, “large”) result: (“normal”: 18px) |
|
Returns all the value in map and generates a queue. Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-values ($font-sizes) result: 12px, 18px, 24px |