css calc invalid property value

css calc parent width
css min invalid property value
css max invalid property value
css calc(auto)
css invalid property value
css calc window height
css calc string
css calc round

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));

You can't divide by units like px, only numbers.

CSS3 calc(100%-88px) not working in Chrome, https://www.w3.org/TR/css3-values/#calc-syntax A property that is struck in when viewed in Chrome's developer tools may be valid but a property struck through and with a warning triangle icon next to it is invalid. When calc() is used correctly (length units used as a value to a property), it sadly calc() won’t work when applied to media queries. @media (max-width: 40rem) { /* Narrower or exactly 40rem */ } /* Nope! */ @media (min-width: calc(40rem + 1px)) { /* Wider than 40rem */ }

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/

calc(), When + operator is used, CSS calc() function will result into an invalid property value. Status: Assignee: Resolution: Closed. Hong Zhao. Fixed. DRY State Switching With CSS Variables: Fallbacks and Invalid Values. This is the second post in a two-part series that looks into the way CSS variables can be used to make the code for complex layouts and interactions less difficult to write and a lot easier to maintain.

When using calc() you can't divide by pixels, you can only divide by unitless numbers. Also, the number you are dividing has to have a certain unit like px, em, vh, vw.

For example, if you need to set a width of an element you should use:

width: (100px / 2); //this equals to 50px

An important note is to make sure you put spaces between the operator signs. This calc() article provides further detailed explanation on the function.

[#LPS-70588] When + operator is used, CSS calc() function will , The only place you can use the calc() function is in values. See these examples It could be used for only part of a property too, for example: .el { /* Valid */ margin: calc(10px + 10px); /* Invalid */ margin: calc(10px + 5); }. I noticed that my usage of the CSS3 calc () function as the unit for width is not working in the latest version of Chrome. In the Chrome Developer tools, the rule with calc () has a strikethrough through it and an exclamation mark in a yellow triangle to the left of it. This is signaling that the property or value is not recognized.

As Stephen Thomas has answered, you can't divide by units. To get around this, just divide the numbers as numbers and then assign the unit of measurement by multiplying the result by 1 unit of the units you're interested in. In your nested scenario you'd need to figure out what unit of measurement you were after in the end so that you could divide the numbers and then assign the result to a px or vw unit of measurement.

A Complete Guide to calc() in CSS, on Jun 14, 2019. If you look at the styles in developer tools you'll see. min-height: calc(100vh-89px);. lined out due to an invalid property value. The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> is allowed.

I just came across this error because one SCSS variable was set to zero:

WRONG:

$card-border-width: 0;

This eventually provoked Chrome's message Invalid property value in answer to the CSS result border-radius: 0 0 calc(0.25rem - 0) calc(0.25rem - 0).

RIGHT:

$card-border-width: 0rem;

(giving border-radius: 0 0 calc(0.25rem - 0rem) calc(0.25rem - 0rem))

Footer not sticking to the bottom of the page, The value definition field of each CSS property can contain keywords, data types with the number 1 and the identifier em2em, which is an invalid unit. This means that width: calc(500px + 50%); is allowed—both values are  The calc () function performs a calculation to be used as the property value. The numbers in the table specify the first browser version that fully supports the function. Numbers followed by -webkit-, -moz-, or -o- specify the first version that worked with a prefix. Thank You For Helping Us! Your message has been sent to W3Schools.

CSS Values and Units Module Level 3, So, for short demonstration: calc(100% + 120px) becomes calc(100%+120px) after activation and this leads to an invalid property value, so it's not working  calc() is a native CSS way to do simple math right in CSS as a replacement for any length value (or pretty much any number value). It has four simple math operators: add (+), subtract (-), multiply (*), and divide (/). Being able to do math in code is nice and a welcome addition to a language that is fairly number heavy.

CSS optimizing removes necessary spaces from calc-function , The CSS calc function is used to perform calculations when specifying and uses the result as the value of the CSS property where it is used. So, calc(​100px * 20px) and calc(700 / 40px) are invalid while calc(100px * 20)  CSS calc() invalid property value CSS calc 함수 invalid property value. calc() 내부의 계산식에서 연산자 앞뒤를 붙여쓰면 발생하는 오류; 테스트 환경 Chrome 버전 49.0.2623.112 m; 2 예시 . 오류 사례

The CSS Calc Function - DEV Community ‍ ‍ , The value is 1.25 rem instead of 1.25rem (unwanted space). Same thing for custom block font sizes. Looks like it's related to calc and appears  Also, maybe it’s worth noting that the CSS Generated Content Level 3 spec draft seems to differentiate the single image value for the content property from the mix of the text and images: the former is called “content-replacement” and should behave like the regular img element (including resizing) while the latter is called “content

Comments
  • This is crazy. This is not the way to use calc property its not for this much of calculation
  • Chrome also rejects width: calc((5) / (2));
  • @Gaurav Aggarwal: why not
  • I am having same error message for the code .war{min-height:calc(100vh-((100vh - 162.5)-300px))!important;}
  • @ Olanrewaju T: You need to have white space around your operators so your calculation should look like this: .war{min-height:calc(100vh - ((100vh - 162.5) - 300px)) !important;}
  • This solved the problem. Incredible how a whitespace could have such a great impact over the CSS.
  • Never in my life have I seen a language where whitespaces between operators matter...