44
48

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.

CSS3 Flexbox 並べ方まとめ

Last updated at Posted at 2015-07-31

Flexboxプロパティをまとめてみた
今回はflex-floworder

準備


<div id="flex">
  <div class="flex-item">A</div>
  <div class="flex-item">B</div>
  <div class="flex-item">C</div>
  <div class="flex-item">D</div>
  <div class="flex-item">E</div>
  <div class="flex-item">F</div>
  <div class="flex-item">G</div>
</div>


*{
  margin: 0;
  padding: 0;
}

/* #flexを画面中央に配置 */
html,body{
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* flex-container */
#flex{
  background: #55BE2E;
  display: flex;
  width: 200px;
  height: 200px;
}

.flex-item{
  font-size: 3em;
}

flex-flow

flex-flowは flex-directionとflex-wrapをまとめて指定できるショートハンド。
flexコンテナに指定する。

flex-flow: row nowrap; (横並び 単一行)

rnw.png

flex-flow: row wrap; (横並び 複数行)

rw.png

flex-flow: row wrap-reverse; (横並び 逆順複数行)

row_wrapRE.png

flex-flow: row-reverse nowrap; (逆順横並び 単一行)

rrnw.png

flex-flow: row-reverse wrap; (逆順横並び 複数行)

rrw.png

flex-flow: row-reverse wrap-reverse; (逆順横並び 逆順複数行)

rowRE_wrapRE.png

flex-flow: column nowrap; (縦並び 単一行)

cnw.png

flex-flow: column wrap; (縦並び 複数行)

cw.png

flex-flow: column wrap-reverse; (縦並び 逆順複数行)

column_wrapRE.png

flex-flow: column-reverse nowrap; (逆順縦並び 単一行)

crnw.png

flex-flow: column-reverse wrap; (逆順縦並び 複数行)

crw.png

flex-flow: column-reverse wrap-reverse; (逆順縦並び 逆順複数行)

columnRE_wrapRE.png

order

orderはFlexアイテムの配置順序を指定できる
配置順序を変えてもDOMの構造は変わらない

order.png


.flex-item:nth-child(1){
  order: 5;
}

.flex-item:nth-child(2){
  order: 3;
}

.flex-item:nth-child(3){
  order: 2;
}

.flex-item:nth-child(4){
  order: 6;
}

.flex-item:nth-child(5){
  order: 4;
}

.flex-item:nth-child(6){
  order: 1;
}

.flex-item:nth-child(7){
  order: 7;
}

次回:CSS3 Flexbox 位置の揃え方まとめ

44
48
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
44
48

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?