Roy
Roy

Reputation: 105

Can Sass perform mixed arithmetics?

I am in a bit of a dilemma here... According to this stack overflow question's accepted answer, Sass cannot process expressions involving px and % together. However, if I go to the Sass Guide and scroll down to the Operators section, there is a very clearly written expression involving px and % together. Is this a mistake in the Sass documentation, or does this expression really work?

Upvotes: 0

Views: 42

Answers (1)

Paulie_D
Paulie_D

Reputation: 115045

Without knowing what it is you are trying to achieve it's hard to answer. The operators you are referring to are converting px to %...not adding incompatible value expressions.

And yes, the SASS guide is correct and it does work.

Input

div {
  width: 600px / 900px *  100%;
}

Output

div {
  width: 66.66666667%;
}

https://www.sassmeister.com/gist/7fde603028e0ab2f47609523b8ea7894

Upvotes: 1

Related Questions