Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Sass Map Functions

Sass Map Functions

Sass Functions Sass Functions

A Sass Map object is represented by one or more key/value pairs.

Sass Map is immutable, so when processing a Map object, a new Map object is returned rather than modifying the original Map object.

The following table lists Sass's Map functions:

function Description & Examples
map-get(map, key) Return from the Map key the corresponding value. If there is no matching key, return null.
 **实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 map-get($font-sizes, "small")       

 结果: 12px |

| map-has-key(map, key) | Determine whether map has a corresponding key; return true if it exists, otherwise false.

 **实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 map-has-key($font-sizes, "big")       

 结果: false |

| map-keys(map) | Return map a list of all keys in the map.

 **实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 map-keys($font-sizes)       

 结果: "small", "normal, "large" |

| map-merge(map1, map2) | Merge two maps into a new map type, that is, append map2 to map1to the end of

 ** 实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 $font-sizes2: ("x-large": 30px, "xx-large": 36px)       

 map-merge($font-sizes, $font-sizes2)       

 结果: "small": 12px, "normal": 18px, "large": 24px, "x-large": 30px, "xx-large": 36px |

| map-remove(map, keys...) | Remove map the keys from the map, with multiple keys separated by commas.

 **实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 map-remove($font-sizes, "small")       

 结果: ("normal": 18px, "large": 24px)       

 map-remove($font-sizes, "small", "large")       

 结果: ("normal": 18px) |

| map-values(map) | Return map all values from the map and generate a list.

 **实例:**       

 $font-sizes: ("small": 12px, "normal": 18px, "large": 24px)       

 map-values($font-sizes)       

 结果: 12px, 18px, 24px |


Sass Functions Sass Functions