Why CSS Calc() function only requires spaces before and after the "+" or "-" operator
P粉004287665
2023-08-31 22:22:29
<p>For example: <code>calc(10px 2px);</code> is correct
but
<code>calc(10px 2px);</code> gives an error
or
<code>calc(10px - 2px);</code> is c or rect
but
<code>calc(10px -2px);</code> gives an error or. However, this does not apply to other operations</p>
For the
operator, the operation may be slightly more complicated thancalc(10px 2px);. I mean something likecalc(5px -1px);is actually more complex and impossible to becalc(5px -1px);.For the
-operator, how does CSS know whether-is the minus operator or part of a negative number? I mean logically.Additionally, whitespace makes code easier for humans to read.
Learn more about CSS
calc()function in the documentation.