LoginSignup
12
8

More than 5 years have passed since last update.

flexboxを使った中央寄せについて

Last updated at Posted at 2017-04-10

flexboxを使った上下左右の中央寄せで詰まったのでメモしておく。

flexbox使い方

親要素に、display:flex;を指定する。
すると子要素は自動的にflex itemになる。

「flex-direction」

子要素の配置方向を決める。
row : 子要素が左から右に配置される。
column : 上から下に配置される。
row-reverse : 右から左に配置。
column-reverse : 下から上。

詰まったのが以下↓

flex-directionのcolumnとrowの指定の仕方によって、揃える方向が逆転する。

justify-content:水平方向の揃え方(しかし、flex-direction: column;指定の場合は、垂直方向に揃える。)
align-items:垂直方向の揃え方(しかし、flex-direction: column;指定の場合は、水平方向に揃える。)

参考
https://liginc.co.jp/web/html-css/css/21024

12
8
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
12
8