I compare different CSS values of the same CSS declaration applied to the same element from different style sheets and to get the final CSS value I use getComputedStyle()
. I know that it returns computed values in px. But is it possible at that to get the real value in percents from the very CSS?
I mean with the code
let element = document.querySelector('.col');
console.log(window.getComputedStyle(element).width);
.col{
width:40%;
}
.col{
width:50%;
}
<div class="col"></div>
I get a value in px, but I would like to get 50% specfied in the very CSS
Is there a way?