css弹性盒模型学习
开启盒模型:加入display:flex这句话就开启
/*行内弹性盒子*/
display: inline-flex;

flex-direction:设置flex的排序属性,默认为行:row
可设置 flex-direction: row;flex-direction: row-reverse;
flex-direction: column-reverse; flex-direction: column;
添加reverse表示翻转,效果如下


flex-wrap: 该属性控制元素内容装不下时是否换行:(该属性也有翻转属性-reverse)
在不换行(默认)时,元素的内容会随之变小

在加了换行后元素会换行显示

justify-content:该属性设置元素在主轴的排列
/* 排列方式对齐到主轴的开始、 */
/* justify-content: flex-start; */
/* 排列方式对齐到主轴的结束、 */
justify-content: flex-end;
/* 居中、 */
justify-content: center;
/* 左右紧挨边缘,其余平均分布 */
justify-content: space-between;
/* 绝对平均分布 */
justify-content: space-evenly;





align-items:该属性设置交叉轴的对齐方式(单行元素)
align-items: flex-end;
align-items: flex-start;
align-items: center;



align-content:该属性设置侧轴多行时,它们的对齐方式
align-content: flex-start;
align-content: flex-end;
align-content: center;
align-content: space-between;
align-content: space-evenly;





flex-grow:元素可用空间分配
article div:nth-child(1) {
flex-grow: 0;
}
article div:nth-child(2) {
flex-grow: 2;
}
article div:nth-child(3) {
flex-grow: 4;
}

用以上属性简写布局
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { margin: 0; padding: 0; } body { height: 100vh; display: flex; flex-direction: column; } header { background-color: teal; height: 100px; } main { background-color: crimson; flex-grow: 1; display: flex; } footer { background-color: teal; height: 100px; } main div:nth-child(1) { background-color: turquoise; flex-grow: 1; } main div:nth-child(2) { background-color: rgb(177, 19, 106); flex-grow: 5; } main div:nth-child(3) { background-color: turquoise; flex-grow: 1; } </style></head><body> <header></header> <main> <div>left</div> <div>main</div> <div>right</div> </main> <footer></footer></body></html>

order:元素排序属性,值越大,元素排序越靠后
