批改状态:合格
老师批语:总结过于简单,建议修改下标题,填充点内容,附上图片!
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>盒/框模型</title><style>.box {/* 宽高叫内容区 */width: 200px;height: 200px;}.box.one {/* 上右下左,顺时针方向 */padding: 10px;/* 浏览器计算有规则,有误差,这是正常的,你看到的是 */border: 2px solid red;background-color: lightgreen;/* 内容裁切 只到内容区,就能看到padding*/background-clip: content-box;/* margin:top right bottom left; *//* margin: 0 0 20px 0; */margin-bottom: 20px;}.box.two {padding: 10px;border: 2px solid red;background-color: coral;background-clip: content-box;/* 当二个盒子在垂直方向,外边距产生折叠 */margin-top: 30px;}.box.dad {background-color: lightseagreen;/* 一旦一个元素被添加了position,且值不是static(默认值),那么它就是定位元素 */position: relative;/* 从浏览器左边过来50,也可以从上面过来; *//* 相对定位,相对自己做了偏移,也就是这个元素在文档中的位置不释放 *//* left: 50px; *//* top: 50px; */}.son {width: 100px;height: 100px;background-color: magenta;/* 绝对定位 相对于它的定位父级进行定位 *//* 做下面的定位时,把dad里面的定位值注释掉,然后再打开,作对比 *//* 最大的父级是body */position: absolute;/* 固定位位 他是忽略你的定位父级,总是以body进行定位,如广告*/position: fixed;left: 50px;top: 50px;}</style></head><body><!-- 块元素独占一行,默认垂直排列 --><div class="box one"></div><div class="box two"></div><div class="box dad"><div class="box son"></div></div></body></html>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号