Get Android Chrome Browser Address bar height in JS

后端 未结 5 1964
忘掉有多难
忘掉有多难 2020-12-18 04:39

How do I get the height of the address bar in JavaScript in the Chrome browser for Android (marked by red rectangle in left picture)? I need to know that as it disappears wh

5条回答
  •  清歌不尽
    2020-12-18 05:10

    The thing you're are looking for is url bar resizing. Since Android's chrome v56, it's recommended by David Bokan to use vh unit on mobile. There is a demo in that article, clicks the link to get more informations and how to use it on mobile.

    When the user is scrolling down the page, a window.resize event is throwed. You could update your page by catching this event with an event listener.

    More informations : mobile chrome fires resize event on scroll

提交回复
热议问题