LoginSignup
5
5

More than 5 years have passed since last update.

iOS9での幅取得

Posted at

iOS9での画面幅取得はdocument.documentElement.clientWidthを使用するといいみたい。

iOS8以前ではwindow.innerWidthで画面幅を取得していました。
画面幅を基準にして画像などの幅を変更していた場合、初回読み込み時はいいのですが、縦→横→縦とiPhoneを回転させたときに横向きの画像幅を引き継いでしまいます。
画像の幅が画面幅(clientWidth)より大きいと、画像の幅に合わせて画面幅(innerWidth)を変えてしまうのですね。

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