Im trying to find a way to find the amount of pixels in one VH in reactjs with in-line styling. For example something like
this.num_pixels = calculate(num_vh=50)
Outputs 540 in a 1080 by 1800 computer.
Im trying to find a way to find the amount of pixels in one VH in reactjs with in-line styling. For example something like
this.num_pixels = calculate(num_vh=50)
Outputs 540 in a 1080 by 1800 computer.
Well 1vh = 1% of screen height.
So, it could be something like:
const convertVhToPx = (vh=50) => {
const oneVhInPx = window.innerHeight / 100;
return oneVhInPx * vh;
};
It might not be super-duper precise because there are quite a few quirks with vh units in general but you might easily adjust this snippet a tiny bit to make it work for your particular use case.