批改状态:合格
老师批语:实例演示,要认真对待
Flex是Flexible Box的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性。设为Flex布局以后,子元素的float、clear和vertical-align属性将失效。
* {/* 初始化 */margin: 0;padding: 0;box-sizing: border-box;}body .container {/* width: 500px; */height: 300px;outline: 1px solid darkgrey;display: flex;/* 设置主轴方向 *//* flex-direction: row; *//* 设置换行 *//* flex-wrap: wrap; *//* 简写 */flex-flow: row nowrap;/* 设置主轴对齐 *//* justify-content: center; *//* 设置交叉轴 *//* align-items: center; *//* 设置多行交叉轴对齐 *//* align-content: space-between; *//* 主轴对齐 */place-content: space-evenly;/* 交叉轴的对齐 */place-items: stretch;}body .container .box {width: 30px;min-height: 30px;outline: 1px solid red;/* 放大因子 *//* flex-grow: 1; *//* 缩放因子 *//* flex-shrink: 1; *//* 项目单独设置宽度 *//* flex-basis: auto; *//* 简写flex: 放大因素值 缩放因素值 宽度 *//* flex: 1 1 auto; */flex: auto;}body .container .box:first-child {background-color: coral;/* order 默认值是0,值越小顺序越靠前*/order: 3;/* 控制某一个项目的交叉轴对齐 *//* algin-self:center; */place-self: end;}body .container .box:nth-of-type(2) {background-color: lightgreen;place-self: center;}body .container .box:last-child {background-color: lightblue;order: -1;place-self: start;}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号