Sass Numeric Operators
What is Numeric Operators?
Numeric Operators perform a mathematical operation between numbers. They automatically convert between compatible units.
Note: The unit comes first has higher priority over the following units. For example, consider the following
- 1in - 10px returns 0.8958333333, which is in inches.
- 1px + 1in returns 97, which is in pixels.
Example
Sass Numeric Operators
The following table provides a list of numeric operators available in Sass.
Operator | Explanation | Operation | Result |
---|---|---|---|
+ | adds | 10s + 15s | 25 |
- | subtracts | 1in - 10px | 0.8958333333 |
* | multiplies | 5px * 4 | 20 |
/ | divides | (12px / 4px) | 3 |
% | remainder | 1in % 9px | 0.0625 |
Sass Numeric Operators with Incompatible Units
Numbers with incompatible units can't be used with addition, subtraction, or modulo.
Example
Reminder
Hi Developers, we almost covered 99.1% of Sass Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in Sass.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.