Advertisement:
Read Later
In this article, I will show you how to calculate and evaluate variables in CSS without requiring a preprocessor such as SASS.
Syntax:(*)
The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a
The calc() function takes a single expression as its parameter, with the expression's result used as the value. The expression can be any simple expression combining the following operators, using standard operator precedence rules:
+ Addition
- Subtraction
* Multiplication
/ Division
The operands in the expression may be any
--------------CSS(plain)---------------
.calc{display:block;background-color:white;width:calc(80% - 158px);height:calc((250px / 3) - (12px * 2));margin:auto;}
--------------HTML----------------
<div class="calc"></div>
Result:
(*) https://developer.mozilla.org/en-US/docs/Web/CSS/calc