css calc invalid property value

Josh picture Josh · Nov 25, 2015 · Viewed 27.2k times · Source

Can someone tell me why this CSS calc function isn't working? When I inspect element on Chrome, it says 'Invalid property value'.

width: calc((100vw - 14px * 2) / (270px + 11px * 2));

Answer

cssyphus picture cssyphus · Mar 12, 2018

For future googlers:

The unhelpful "invalid property value" message in DevTools might just mean that you need white space around your + - / * operators.

Incorrect (invalid property value):

width:calc(100vh-60px)  <== no spaces around minus sign

Correct:

width:calc(100vh - 60px) <== white space around the minus sign

The OP's question above does not have this problem, but while googling an answer to this error message this is the first resource I found, so it should have an answer dedicated to this common error.

References:

CSS3 calc() not working in latest chrome

https://www.smashingmagazine.com/2015/12/getting-started-css-calc-techniques/