LoginSignup
2
3

More than 3 years have passed since last update.

スマホのウインドウの高さぴったりにする(アドレスバー分をちゃんと考慮)

Last updated at Posted at 2020-10-18

100vhがうまく行かないというのがよく知られている部分ですが

area.js
setInterval(function(){
        $(".area").css({"height":window.innerHeight,"min-height":$(window).innerHeight()});
},100)

横向きにした時など回転直後など、window.innerHeightの値が異様に小さくなる。
スクロールをしてアドレスバーのエリアが小さくなった時には、$(window).innerHeight()が伸びた分を検知してくれない。

でこれをした時にposition:fixed;をしているときにtop:0だと、隠れたりしてしまうので、オススメはbottom:0;

2
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3