DEV Community

Discussion on: Mobile issue with 100vh | height: 100% !== 100vh [3 solutions]

Collapse
 
sdoigmm profile image
Steve Doig

This works for me in Chrome on desktop (i.e. it adds the --vh variable to the style of html), but it doesn't add the --vh variable to the style of html in Chrome on a Google Pixel 5. Is this because the --vh variable is only added when the viewport is resized?

(window.addEventListener('resize'...)

Collapse
 
sdoigmm profile image
Steve Doig

I had to add a separate event listener for window's load event to performing the same function to get it to work on mobile.

Collapse
 
piyushkmr profile image
Piyush Kumar Baliyan

I also added a initial window loaded event, in addition to resize.