CSS calc() - Multiplication and Division with unit-ed values

Solution 1:

In CSS calc() division - the right side must be a <number> therefore unit based values cannot be used in division like this.

Also note that in multiplication at least one of the arguments must be a number.

The MDN has great documentation on this.

If you'd like a better way to do calculations you can use a preprocessor (I like Sass). That link will take you to their guides (on that page there's a section about operators).

Solution 2:

For someone who is making a mistake like me, don't forget that you can't use Sass variables in CSS's calc function directly. For that, you have to use Sass's calculation method.

$test: 10px;

.testing{
    width: $test * 2;
}

Or if a calc implementation is necessary:

$test: 10px;

.testing{
  width: calc(50% + #{$test * 2}); // results in calc(50% - 20px)
}