0
0

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.

ブロック要素を縦方向に並べる方法

Last updated at Posted at 2019-06-02

#ブロック要素を縦方向に並べる方法
vertical-alignプロパティではブロック要素に適用できない。ブロック要素中のテキストを縦方向の中央揃えにする方法を調べました。
参考にしたサイト

<div class="box">text</div>
.box {
    width: 100px;
    height: 100px;
    }

下記のCSSを追加すれば実現できる。
##line-height テキストが一行のみ

.box-align {
    line-height: 100px;
}

##table-cell

.box-align {
    display: table-cell;
    vertical-align: middle;
}

##Flexible box

.box-align {
    display: flex;
    align-items: center;
    justify-content: center;
}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?