批改状态:合格
老师批语:
作业内容:将flex容器与项目的常用属性全部进行实例演示,并理解属性的常用值的显示效果
演示地址: https://php.gzj2001.com/1221/index.html
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>1222作业</title><style>/* 初始化一些默认参数 并使用IE盒子 */* {padding: 0;margin: 0;box-sizing: border-box;}/* 将容器转换为flex弹性容器 */.container {/* 转换flex容器 */display: flex;/* 添加边框便于观察 */border: 1px solid red;/* 设置高度 */height: 20em;/* 设置内边距 */padding: 1em;/* 设置外边距 */margin: 1em;/* 弹性容器主要属性 *//* 主轴方向与是否换行 */flex-flow: row wrap;/* 一行项目在主轴上的位置 *//* justify-content:center; *//* 一行项目在交叉轴上的位置 *//* align-items: center; */}.container>.item {/* 给项目添加背景色便于观察 */background-color: lightyellow;/* 给项目添加边框便于观察 */border: 1px solid springgreen;/* 设置宽度便于观察 */width: 5em;}/* 项目常用属性 flex展示 【设置基本项目的伸缩与宽度】 */.container .item {/* 默认 */flex: initial;/* 允许放大 和 缩放 */flex: auto;/* 禁止放大和 缩放 */flex: none;}/* 项目常用属性 align-self展示 【某个项目的对齐方式 】 *//* 以第八个项目为例来展示 */.container .item:nth-of-type(8) {/* 默认伸展 */align-self: stretch;/* 从上往下 *//* align-self: flex-start; *//* 从下往上 *//* align-self: flex-end; *//* 居中 *//* align-self: center; */}/* 项目常用属性 order展示 【置某个项目在主轴上的排列顺序】*/.container .item:nth-of-type(1) {background-color: green;order: 2;}.container .item:nth-of-type(2) {background-color: #000;order: 5;}.container .item:nth-of-type(3) {background-color: #fff;order: 1;}.container .item:nth-of-type(4) {background-color: #456789;order: 4;}.container .item:nth-of-type(5) {background-color: #987654;order: 8;}.container .item:nth-of-type(6) {background-color: #redorder: -1;}.container .item:nth-of-type(7) {background-color: #658963;order: 6;}</style></head><body><div class="container"><div class="item">1</div><div class="item">2</div><div class="item">3</div><div class="item">4</div><div class="item">5</div><div class="item">6</div><div class="item">7</div><div class="item">8</div></div></body></html>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号