[TIL] CSS 3: Flexbox


Display

{display: block;}
{display: flex;}
{display: inline-flex;}

Main axis


1. Justify-content

{justify-content: flex-start;}
{justify-content: flex-end;}
{justify-content: center;}
{justify-content: space-around;}
{justify-content: space-between;}

2.Flex grow拡大縮小Flex収縮


  • Step 1
  • .top.side {flex-grow: 1;}
    .top.center {flex-grow: 1;}
  • Step 2
  • .middle.side {flex-grow: 2;}
    .middle.center {flex-grow: 1;}
  • Step 3
  • .bottom.side {flex-grow: 1;}
    .bottom.center {flex-grow: 2;}

    3. Flex-basis


  • Grow
  • .grow.side {
    flex-basis: 60px;
    flex-grow: 1;
    }
    .grow.center {
    flex-grow: 3;
    }
  • Shrink
  • .shrink.side {
    flex-basis: 300px;
    flex-shrink: 3;
    }
    .shrink.center {
    flex-shrink: 2;
    flex-basis: 150px;
    }
  • Flex:grow shriftに基づいて1行で作成
    ex) {flex: 2 2 100px ;}
  • 4. Flex-wrap

  • 改行に該当しない領域は、次の行に移動します.
  • wrap-reverse
  • nowrap
  • Cross axis


    1. Align-items

  • Align-items
  • {align-items: flex-start;}
    {align-items: flex-end;}
    {align-items: center;}
    {align-items: baseline;}
  • Stretch
  • {min-height: 75px ;}
    max-height:'}

    2. Align-content



    (+)


    1. Flex-direction


    Flex方向プロパティの追加


    2. Flex-flow


    1行にFlex wrapとFlex directionプロパティを作成します.
  • はdirection->wrap順に記入する必要があります!{flex-flow: column wrap;}