user6818880
user6818880

Reputation:

Is there a power function in CSS?

I know you can write a power function in Sass with a loop. Is there one specifially in CSS? Or a way to write one?

Upvotes: 5

Views: 3901

Answers (1)

Temani Afif
Temani Afif

Reputation: 274237

The working group already approved such functions

The CSS Working Group just discussed trig, and agreed to the following:

RESOLVED: Add sin() cos() tan() acos() asin() atan() atan2() hypot() sqrt() pow()

And it's now under the CSS Values and Units Module Level 4 Specification:

The exponential functions pow(), sqrt(), hypot(), log(), and exp() compute various exponential functions with their arguments.

The pow(A, B) function contains two comma-separated calculations A and B, both of which must resolve to <number>s, and returns the result of raising A to the power of B, returning the value as a <number>.

We only need to wait for their support by the browsers

Upvotes: 8

Related Questions