1.1 KiB
1.1 KiB
Calc()
The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.
HTML
<div class="box-example"></div>
CSS
.box-example {
width: calc(100% - 60px);
}
Demo
Box Example
Explanation
- It allows addition, subtraction, multiplication and division.
- Can use different units (pixel and percent together, for example) for each value in your expression.
- It is permitted to nest calc() functions.
- It can be used in any property that
<length>,<frequency>,<angle>,<time>,<number>,<color>, or<integer>is allowed, like width, height, font-size, top, left, etc.
Browser support
✅ No caveats.