Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Sass 映射函数


Sass 映射函数

在 Sass 中,map 数据类型表示一个或多个键/值对。

提示:也可以使用上一页的列表函数来处理映射。然后,映射将被视为具有两个元素的列表。

Sass 映射是不可变的(它们不能更改)。因此,返回映射的映射函数将返回一个新映射,而不是更改原始映射。

下表列出了 Sass 中的所有映射函数

函数 描述 & 示例
map-get(map, key) 返回映射中指定key的值。

示例
$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)
map-get($font-sizes, "small")
结果:12px
map-has-key(map, key) 检查map是否包含指定的key。返回 true 或 false。

示例
$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)
map-has-key($font-sizes, "big")
结果:false
map-keys(map) 返回map中所有键的列表。

示例
$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)
map-keys($font-sizes)
结果:"small", "normal", "large"
map-merge(map1, map2) map2附加到map1的末尾。

示例
$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...) map中移除指定的键。

示例
$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) 返回map中所有值的列表。

示例
$font-sizes: ("small": 12px, "normal": 18px, "large": 24px)
map-values($font-sizes)
结果:12px, 18px, 24px

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.