16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Modalコンテンツの幅を%指定したときに左右天地の中央に配置するCSS設定

Posted at

transformのtranslateを利用する。translateはX軸とY軸に指定したサイズ分移動する。

css
#modal_content {
    width: 80%;
    height:80%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

結果

縦幅、横幅のサイズが不明なコンテンツが左右天地中央に配置される。

16
15
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
16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?