I`m trying to make responsive mobile menu, and faced some problems with differents between viewports in Google Chrome mobile and other browsers. See screenshots below:
By green color I paint viewport border. The first image here made in chrome mobile, and the second in default device browser. On mobile IOS the result is the same as on the last image. Red button, book the studio is fixed with bottom 0. And it must always be on the bottom of the screen. So, the questions is:
Why chrome makes the viwport height greater than it realy is?
What is the best way to handle this?
Set viewport meta tag also does not help.
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=0" />
Could someone advice?
Unfortunately this is intentional…
This is a well know issue (at least in safari mobile), which is intentional, as it prevents other problems. Benjamin Poulain replied to a webkit bug:
Nicolas Hoizey has researched this quite a bit: https://nicolas-hoizey.com/2015/02/viewport-height-is-taller-than-the-visible-part-of-the-document-in-some-mobile-browsers.html
No fix planned
At this point, there is not much you can do except refrain from using viewport height on mobile devices. Mobile Chrome seems to want to adapt this too, although it is not sure if they will follow through.
The only one way to solve this issue is to use this snippet:
where 60px is top nav height, which may be different depend of device