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;
}
2.2 flex-wrap
- 默认情况下,项目都排在一条线(又称"轴线")上。flex-wrap`属性定义,如果一条轴线排不下,如何换行。
.box{
flex-wrap: nowrap | wrap | wrap-reverse;
}
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;
}
2.5 align-items
.box {
align-items: flex-start | flex-end | center | baseline | stretch;
}
2.6 align-content
- 属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用
.box {
align-content: flex-start | flex-end | center | space-between | space-around | stretch;
}