Sass 简介
Sass 安装
Sass 变量
Sass Nested Rules and Properties
Sass @import and Partials
Sass @mixin and @include
Sass @extend and Inheritance
Sass 函数
Sass String
Sass Numeric
Sass List
Sass Map
Sass Selector
Sass Introspection
Sass Color
Sass Map - SASS基础教程 - 笔下光年
网站首页
Sass Map
In Sass, the map data type represents one or more key/value pairs. Tip: It is also possible to use the List functions from the previous page, with maps. Then the map will be treated as a list with two elements. Sass maps are immutable (they cannot change). So, the map functions that return a map, will return a new map, and not change the original map. The following table lists all map functions in Sass: | Function | Description & Example | |---------------------|----------------| | map-get(map, key) | Returns the value for the specified key in the map. <br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/>`map-get($font-sizes, "small")`<br/>Result: `12px` | | map-has-key(map, key) | Checks whether map has the specified key. Returns true or false.<br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/>`map-has-key($font-sizes, "big")`<br/>Result: `false` | | map-keys(map) | Returns a list of all keys in map.<br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/>`map-keys($font-sizes)`<br/>Result: `"small", "normal, "large"` | | map-merge(map1, map2) | Appends map2 to the end of map1. <br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/> `$font-sizes2: ("x-large": 30px, "xx-large": 36px)`<br/>`map-merge($font-sizes, $font-sizes2)`<br/>Result: `"small": 12px, "normal": 18px, "large": 24px, "x-large": 30px, "xx-large": 36px` | | map-remove(map, keys...) | Removes the specified keys from map.<br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/>`map-remove($font-sizes, "small")`<br/>Result: `("normal": 18px, "large": 24px)`<br/>`map-remove($font-sizes, "small", "large")`<br/>Result: `("normal": 18px)` | | map-values(map) | Returns a list of all values in map.<br/><br/>**Example:**<br/>`$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)`<br/>`map-values($font-sizes)`<br/>Result: `12px, 18px, 24px` |
上一篇:
Sass List
下一篇:
Sass Selector