LoginSignup
0
0

More than 3 years have passed since last update.

[css] どれだけスクロールしても常に画面いっぱいに表示

Last updated at Posted at 2019-07-20

モーダルの背景とかによく使う

hoge.css
.target-class {
  position: fixed;
  height: 100vh;
  width: 100vw;
  z-index: 350;
  top: 0;
  left: 0;
}

position: fixed = 画面上の任意の位置に固定
vh(view height) = 画面の縦幅、100vhで縦幅いっぱい
vw(view width) = 画面の横幅、100vwで横幅いっぱい
z-index = 重なりの優先順位、前面に出したいなら相対的に大きな値にする
top: 0 = 画面上にくっつける
left : 0 = 画面左にくっつける

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