Sass Number Functions
Sass number functions are used to process numeric values.
The following table lists Sass's number functions:
| function | Description & Examples |
|---|---|
| abs(number) | Return the absolute value of a number. |
**实例:**
abs(15)
结果: 15
abs(-15)
结果: 15 |
| ceil(number) | Round up
**实例:**
ceil(15.20)
结果: 16 |
| comparable(num1, num2) | Return a boolean indicating whether num1 The difference between num2 can be compared
**实例:**
comparable(15px, 10px)
结果: true
comparable(20mm, 1cm)
结果: true
comparable(35px, 2em)
结果: false |
| floor(number) | Round down
**实例:**
floor(15.80)
结果: 15 |
| max(number...) | Return the maximum value
**实例:**
max(5, 7, 9, 0, -3, -7)
结果: 9 |
| min(number...) | Return the minimum value
**实例:**
min(5, 7, 9, 0, -3, -7)
结果: -7 |
| percentage(number) | Convert a number into a percentage expression.
**实例:**
percentage(1.2)
结果: 120 |
| random() | Return a decimal within the range 0-1,
**实例:**
random()
结果: 0.45673 |
| random(number) | Return an integer between 1 and number, inclusive of 1 and limit.
**实例:**
random(6)
结果: 4 |
| round(number) | Return the nearest integer to the number, rounding to the nearest whole number.
**实例:**
round(15.20)
结果: 15
round(15.80)
结果: 16 |
Sass Functions