I know we can get all the styles applied to an element using window.getComputedStyle()
but the problem I am facing is that it converts different units to px
. I want to fetch all the styles just like they appear in the style tab of the dev tool.
For example, It converts the line-height of 1.2
to 57.6px
but I need 1.2
. Is there a way to achieve that using pure JavaScript I am using React so I don't want to use jQuery.
I already went through this question. The accepted answer suggests that one should use computedStyleMap
but this method does not work on every browser another answer suggests using getMatchedCSSRules
but now getMatchedCSSRules
function is not available, it is removed.