学习文档:www.ruanyifeng.com/blog/2015/0…
容器的属性
以下6个属性设置在容器上
- flex-direction
- flex-wrap
- flex-flow
- justify-content
- align-items
- align-content
-
flex-direction:决定主轴的方向
- row(默认值):主轴为水平方向,起点在左端。
- row-reverse:主轴为水平方向,起点在右端。
- column:主轴为垂直方向,起点在上沿。
- column-reverse:主轴为垂直方向,起点在下沿。
-
flex-wrap:如何换行
- nowrap(默认):不换行。
- wrap:换行,第一行在上方。
- wrap-reverse:换行,第一行在下方。
-
flex-flow
-
justify-content
-
align-items
-
align-content
flex-direction:决定主轴的方向
-
row(默认值):主轴为水平方向,起点在左端。
-
row-reverse:主轴为水平方向,起点在右端。
-
column:主轴为垂直方向,起点在上沿。
-
column-reverse:主轴为垂直方向,起点在下沿。
flex-wrap:如何换行
- nowrap(默认):不换行。
- wrap:换行,第一行在上方。
- wrap-reverse:换行,第一行在下方。
flex-flow:是flex-direction属性和flex-wrap属性的简写形式,
默认值为row nowrap。flex-flow: flex-direction || flex-wrap;
align-content、align-items、align-self的区别
- align-content、align-items 是父元素上的属性
- align-self是子元素上的属性
- align-content是多个侧轴,多个交叉轴的属性起作用的,如果只有一个轴不起作用
- align-items是一个轴的的时候起作用