Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox: calc() invalid property value

I have an element with a line-height set with calc():

line-height: calc(3rem / 2);

Demo: http://codepen.io/Ghodmode/pen/vLxZZd

It works fine in Chrome, but Firefox's Developer Tools says that it's an invalid property value.

I'm sure I'm missing something that should be obvious.

Just for reference:

  • https://developer.mozilla.org/en/docs/Web/CSS/calc
  • http://caniuse.com/#search=calc
like image 294
Vince Avatar asked Jan 06 '16 03:01

Vince


People also ask

How do I fix invalid property value in CSS?

To fix that, copy the code directly from you IDE to some "Hidden Character" detector like this one https://www.soscisurvey.de/tools/view-chars.php ,delete the 'bad' characters and then save your code again without the bad characters.

How does the CALC () function work on values in CSS?

CSS calc() is a function used for simple calculations to determine CSS property values right in CSS. The calc() function allows mathematical expressions with addition (+), subtraction (-), multiplication (*), and division (/) to be used as component values.


1 Answers

This is a known issue. Firefox does not currently support calc() values on properties that accept either lengths or numbers, of which line-height is one such property. See bug 594933.

Since 3rem / 2 is exactly 1.5rem you can just hardcode that amount instead as a workaround.

like image 128
BoltClock Avatar answered Oct 05 '22 10:10

BoltClock