Thanks Nikola! No matter which of the three methods you prefer, I would suggest two improvements.
// Add unit to value font-size: 1 + rem + 1rem; // → string '1rem1rem' // Convert unit font-size: 1 * 1rem + 1rem; // → 2rem
math.div
/
@use 'sass:math'; @function pxToRem($pxValue) { @return math.div($pxValue, 16px) * 1rem; } div { width: pxToRem(400px); // → 25rem }
Amazing, it's fully supported!
We're a place where coders share, stay up-to-date and grow their careers.
Thanks Nikola! No matter which of the three methods you prefer, I would suggest two improvements.
math.divfor division instead of/operator as using/for division is deprecated and will be removed in Dart Sass 2.0.0.Amazing, it's fully supported!