CSS 100vh is too tall on mobile due to browser UI

前端 未结 4 1747
萌比男神i
萌比男神i 2021-02-02 09:22

What is the best way to solve this issue. Obviously all browsers on mobile have got a UI (address bar etc) at the top. This adds additional height to the viewport, so my website

4条回答
  •  一向
    一向 (楼主)
    2021-02-02 09:53

    If the element is a direct child of body, you can achieve the desired effect with:

    html, body {
        height: 100%;
    }
    
    #screenheight {
        height: 100%;
        background-color: blue;
    }

    Random content after screenheight element.

提交回复
热议问题