Conversion Table
Viewport Height | Root Em |
---|---|
0.01vh | 0.0068rem |
0.03vh | 0.0203rem |
0.05vh | 0.0338rem |
0.08vh | 0.0541rem |
0.1vh | 0.0675rem |
0.15vh | 0.1013rem |
0.2vh | 0.135rem |
0.5vh | 0.3375rem |
0.625vh | 0.4219rem |
0.75vh | 0.5063rem |
0.875vh | 0.5906rem |
1vh | 0.675rem |
1.125vh | 0.7594rem |
1.25vh | 0.8438rem |
1.375vh | 0.9281rem |
1.5vh | 1.0125rem |
1.625vh | 1.0969rem |
1.75vh | 1.1813rem |
1.875vh | 1.2656rem |
2vh | 1.35rem |
2.125vh | 1.4344rem |
2.25vh | 1.5188rem |
2.375vh | 1.6031rem |
2.5vh | 1.6875rem |
2.625vh | 1.7719rem |
2.75vh | 1.8563rem |
2.875vh | 1.9406rem |
3vh | 2.025rem |
3.125vh | 2.1094rem |
3.25vh | 2.1938rem |
3.375vh | 2.2781rem |
3.5vh | 2.3625rem |
3.625vh | 2.4469rem |
3.75vh | 2.5313rem |
3.875vh | 2.6156rem |
4vh | 2.7rem |
5vh | 3.375rem |
6vh | 4.05rem |
8vh | 5.4rem |
10vh | 6.75rem |
15vh | 10.125rem |
20vh | 13.5rem |
30vh | 20.25rem |
40vh | 27rem |
50vh | 33.75rem |
60vh | 40.5rem |
80vh | 54rem |
100vh | 67.5rem |
Differences Between vh and rem
Viewport Height (vh) is a relative unit that scales according to 1% of the height of the viewport. Root Em (rem) is also a relative unit, but it scales according to the root element's font size, typically the HTML element. vh units are useful for scalable and responsive design, while rem units provide consistency across different elements.
Advantages of Using vh
Using vh units allows for better scalability and flexibility in web design. Since vh is relative to the height of the viewport, it enables elements to scale proportionally to the viewport height. This is useful for responsive design and for creating layouts that adapt to different screen sizes.
How to Convert vh to rem
To convert vh to rem, you need to know the height of the viewport and the root font-size. The formula for conversion is:
rem = vh * (viewport height / 100 / root font-size)
For example, to convert 2vh to rem, assuming the viewport height is 1080px and the root font-size is 16px:
2vh * (1080px / 100 / 16px) = 1.35rem
Frequently Asked Questions
Why should I use vh instead of rem?
Using vh allows for more scalable and flexible layouts, improving the responsiveness and adaptability of your design across different screen sizes.
How do I set the viewport height?
The viewport height is determined by the user's device and browser window size. You can use CSS media queries to adjust your layout based on different viewport heights.
Can I use vh for all elements?
Yes, you can use vh for most elements to ensure consistency and scalability across different screen sizes.