LoginSignup
0
0

More than 1 year has passed since last update.

CSSでスマホのアドレスバーの高さに合うように実装する方法。100vhで困った人へ

Posted at

スマホの画面上のURLが書いてある部分のせいで、heightを100vhにしても意図したデザインにならない問題を解決する方法の備忘録

解決方法は、javascriptのwindow.innerHeightを使用すること

var windowHeight=window.innerHeight;
document.getElementById('section').style.height=windowHeight+'px';

として、100vhでsectionの高さを設定するのではなく、window.innerHeightを使用することで、
アドレスバーの下から画面最下部の大きさで1画面となる。

こちらの記事がとてもわかりやすいです。
https://877.design/smartphone-height/

0
0
0

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
0
0