Description
Cross-browser support for CSS Math Functions:
- Stepped value functions:
round(), mod(), rem()
- Trigonometric functions:
sin(), cos(), tan(), asin(), acos(), atan(), atan2()
- Exponential functions:
pow(), sqrt(), hypot(), log(), exp()
- Sign-related functions:
abs(), sign()
Rationale
Developer needs:
- It will help framework developers, like me, to create complex calculations using CSS.
- My CSS data visualization framework Charts.CSS has no JS, only CSS.
- I can use trigonometric functions to style complex layouts using CSS.
- Additional needs include calculations inside CSS animations.
- Non static layouts - replacing simple units with calculations.
Impact:
- No JS rendering - moving calculations to CSS.
- Faster load time - developer will no longer need to load CSS and JS assets. They can load only CSS.
Browser compatibility:
Safari is leading the way on support. Firefox is catching up.
- Safari 15.4 added support for all those functions.
- Firefox 103 added support for trigonometric functions behind
layout.css.trig.enabled flag.
- Chrome / Edge - no support.
Specification
https://w3c.github.io/csswg-drafts/css-values-4/#math
Tests
Web Platform Tests:
Bug Tracking
WebKit Bugzilla:
Mozilla Bugzilla:
Chromium Bugs:
BCD / MDN
Too many BCD/MDN links, check the main ones:
But, we will finish documenting all the math functions very soon.
Description
Cross-browser support for CSS Math Functions:
round(),mod(),rem()sin(),cos(),tan(),asin(),acos(),atan(),atan2()pow(),sqrt(),hypot(),log(),exp()abs(),sign()Rationale
Developer needs:
Impact:
Browser compatibility:
Safari is leading the way on support. Firefox is catching up.
layout.css.trig.enabledflag.Specification
https://w3c.github.io/csswg-drafts/css-values-4/#math
Tests
Web Platform Tests:
Bug Tracking
WebKit Bugzilla:
Mozilla Bugzilla:
Chromium Bugs:
BCD / MDN
Too many BCD/MDN links, check the main ones:
But, we will finish documenting all the math functions very soon.