I have some constant in rem
s, but rem
itself isn't a constant (depends on media queries and vmin
). For some perpoise I need this value in px
.
Of course I can create a temporary div, set its size to that value in rem
and getComputedStyle
of it to get value in px
. But I'd like to do that without causing a reflow by reading the computed style.
A rem
unit equal to the computed value of ‘font-size’ on the root element. (https://www.w3.org/TR/2013/CR-css3-values-20130730/#font-relative-lengths)
You can get that easily enough with 1 rem =
parseInt(getComputedStyle(document.documentElement).fontSize))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With