Help us understand the problem. What is going on with this article?

CSS3 Flexbox 並べ方まとめ

More than 3 years have passed since last update.

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 位置の揃え方まとめ

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした