scss--函数 (Functions)--unit

  • (Sass::Script::Value::String) unit($number)

Returns the unit(s) associated with a number. Complex units are sorted in alphabetical order by numerator and denominator.

该函数接受一个scss变量,返回该变量表达式的单位。复杂的表达式按照字母排序的顺序进行排序。
复杂的单位是按字母顺序排列的分子和分母排序。
Examples:

unit(100) => ""
unit(100px) => "px"
unit(3em) => "em"
unit(10px * 5em) => "empx"
unit(10px * 5em / 30cm / 1rem) => "em
px/cm*rem"
Parameters:
$number (Sass::Script::Value::Number)
Returns:
(Sass::Script::Value::String) — The unit(s) of the number, as a quoted string
Raises:
(ArgumentError) — if $number isn't a number

posted @ 2017-12-01 17:22  口金十兑  阅读(920)  评论(0编辑  收藏  举报