htmlcssgoogle-chromeaddress-barmobile-chrome

100vh height when address bar is shown - Chrome Mobile


I came across this problem a few times and was wondering if there was a solution to this problem. My problem occurs on the Chrome mobile app. There, you can scroll down a bit and the address bar disappears. So far, so good, let's make an example:
The container's height is set to 100vh.

How it looks with the address bar

As you can see, the bottom part gets cut off.

When I scroll down, it looks like this:

enter image description here

Now it looks good. So obviously Chrome calculates the address bar's height into the viewport height. So my question is:

Is there a way, that it looks the same with or without the address bar? So that the container expands or something?


Solution

  • There are now three new viewport units:

    Usage

    If you want the container's height to change depending on whether the address bar is visible, dvh fits your needs perfectly.

    .container {
        height: 100dvh;
    }
    

    Hope this helped!

    Further reading