.container {
display: flex; /* 容器 */
}
容器内的直接子元素变成 flex item,沿主轴排列,默认水平。
justify-content: flex-start | center | space-between | space-around
align-items: stretch | center | flex-start | flex-end
flex-wrap: wrap; /* 放不下换行 */
flex-direction: column; /* 主轴变纵向 */
.item1 { flex: 1; } /* 占 1 份 */
.item2 { flex: 2; } /* 占 2 份 */
/* 经典三栏:左 1 右 1 中间自适应 */
.middle { flex: 1; }
.center {
display: flex;
justify-content: center;
align-items: center;
}
.nav {
display: flex;
justify-content: space-between;
align-items: center;
}
记忆:justify 管主轴、align 管交叉轴。flex: 1 是 flex-grow:1; flex-shrink:1; flex-basis:0% 的简写。