综合自阮一峰:http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html
在线实例:https://codepen.io/LandonSchropp/pen/KpzzGo
首先,设置为flex布局:
display:flex
采用 Flex 布局的元素,称为 Flex 容器(flex container),简称"容器"。它的所有子元素自动成为容器成员,称为 Flex 项目(flex item),简称"项目"。
容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。
flex-direction: row | row-reverse | column | column-reverse;
决定主轴的方向
justify-content: flex-start | flex-end | center | space-between | space-around;
justify-content用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式。
align-items: flex-start | flex-end | center | baseline | stretch;
定义项目在交叉轴上如何对齐。
align-content: flex-start | flex-end | center | space-between | space-around | stretch;
定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。
align-self: auto | flex-start | flex-end | center | baseline | stretch;
允许单个项目有与其他项目不一样的对齐方式