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表示翻转,效果如下
默认row排列
翻转row排列
flex-wrap: 该属性控制元素内容装不下时能否换行:(该属性也有翻转属性-reverse)
在不换行(默认)时,元素的内容会随之变小
不换行
在加了换行后元素会换行显示
换行
justify-content:该属性设置元素在主轴的排列
/* 排列方式对齐到主轴的开始、 */
/* justify-content: flex-start; */
/* 排列方式对齐到主轴的结束、 */
justify-content: flex-end;
/* 居中、 */
justify-content: center;
/* 左右紧挨边缘,其他平均分布 */
justify-content: space-between;
/* 绝对平均分布 */
justify-content: space-evenly;
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-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;
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;
}
flex-grow:
用以上属性简写布局
<!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:元素排序属性,值越大,元素排序越靠后
order属性
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » css弹性盒模型学习