css浅谈Flex布局

1.打开Flex布局

.box{
  display: flex;
}

2.容器的属性

  • flex-direction
  • flex-wrap
  • flex-flow
  • justify-content
  • align-items
  • align-content

2.1 flex-direction

  • 属性决定主轴的方向(即项目的排列方向)
.box {
  flex-direction: row | row-reverse | column | column-reverse;
}

image-20200717154629094

2.2 flex-wrap

  • 默认情况下,项目都排在一条线(又称"轴线")上。flex-wrap`属性定义,如果一条轴线排不下,如何换行。
.box{
  flex-wrap: nowrap | wrap | wrap-reverse;
}

image-20200717154817073

image-20200717154837297

image-20200717154850081

2.3 flex-flow

  • flex-flow属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap
.box {
  flex-flow: <flex-direction> || <flex-wrap>;
}

2.4 justify-content

  • 属性定义了项目在主轴上的对齐方式
.box {
  justify-content: flex-start | flex-end | center | space-between | space-around;
}

image-20200717155017995

2.5 align-items

  • 属性定义项目在交叉轴上如何对齐
.box {
  align-items: flex-start | flex-end | center | baseline | stretch;
}

image-20200717155056580

2.6 align-content

  • 属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用
.box {
  align-content: flex-start | flex-end | center | space-between | space-around | stretch;
}

image-20200717155140571

posted @ 2020-07-17 16:08  东血  阅读(147)  评论(0编辑  收藏  举报

载入天数...载入时分秒...