1.组成

弹性容器(Flex container)和弹性子元素(Flex item)组成。

display 属性的值为 flex 或 inline-flex将其定义为弹性容器。

2.flex-direction

指定了弹性子元素在父容器中的位置。 flex-direction: row | row-reverse | column | column-reverse

  • row:横向从左到右排列(左对齐),默认的排列方式。
  • row-reverse:反转横向排列(右对齐,从后往前排,最后一项排在最前面。
  • column:纵向排列。
  • image.png
  • column-reverse:反转纵向排列,从后往前排,最后一项排在最上面。

3.justiful-content

内容对齐(justify-content)属性应用在弹性容器上,把弹性项沿着弹性容器的主轴线(main axis)对齐。

justify-content: flex-start | flex-end | center | space-between | space-around

image.png

4.align-items

弹性盒子元素在侧轴(纵轴)方向上的对齐方式。 align-items: flex-start | flex-end | center | baseline | stretch