LoginSignup
2
2

More than 5 years have passed since last update.

CSSだけで画面幅100%を取得する方法。

Posted at

windowの高さ100%をCSSで取得する、のメモ。

基本

・親要素に高さが指定してあれば、相対的に子要素はheight:100%を指定できる。
・親の親に高さが指定してあってもダメ。

手順

・html,bodyにheight:100%を指定する。(htmlの親要素はwindowになるため、html{height:100%}は、windowの高さの100%になる。bodyも同じ。)
・そして、bodyを親要素にもつ、100%にしたい要素にもheight:100%を指定する。

参考

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