conum:
line-height: 4 / 3
The theme language supports basic math operations to calculate key values.
The following table lists the supported operations and the corresponding operator for each.
| Operation | Operator |
|---|---|
multiply |
* |
divide |
/ |
add |
+ |
subtract |
- |
Like programming languages, the multiply and divide operators take precedence over the add and subtract operators.
Here’s an example of a math expression with fixed values.
conum:
line-height: 4 / 3
|
Important
|
Operators must always be surrounded by a space on either side (e.g., 2 + 2, not 2+2). |
Variables may be used in place of numbers anywhere in the expression:
base:
font-size: 12
font-size-large: $base-font-size * 1.25
Values used in a math expression are automatically coerced to a float value before the operation. If the result of the expression is an integer, the value is coerced to an integer afterwards.
|
Important
|
Numeric values less than 1 must have a 0 before the decimal point (e.g., 0.85). |
The theme language also supports several functions for rounding the result of a math expression. The following functions may be used if they surround the whole value or expression for a key.
Rounds the number to the nearest half integer.
Rounds the number up to the next integer.
Rounds the number down the previous integer.
You might use these functions in font size calculations so that you get more exact values.
base:
font-size: 12.5
font-size-large: ceil($base-font-size * 1.25)