批改状态:合格
老师批语:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>定位原理与演示</title></head><body><div class="box paremt"><div class="box child one">child-1:相对定位</div><div class="box child two">child-2:绝对定位</div><div class="box child three">child-3:固定定位</div></div><style>html {height: 2000px;border: red solid 2px;/* position: relative; */}body {height: 500px;border: #000 solid 2px;/* position: relative; */}.box {border: 1px solid #000;}.paremt {background-color: pink;width: 400px;height: 400px;/* position: relative; */}.box.child {padding: 20px;}/* 相对定位relative top向下偏移 left向右偏移 visibility:hidden隐藏 display:noen删除 */.box.child.one {background-color: yellow;position: relative;top: 30px;left: 30px;visibility: hidden;display: none;/* z-index: -1; */}/* 绝对定位absolute :相对于父级(组先级)可定位属性relative 进行定位 只有第一屏展示*/.box.child.two {background-color: beige;position: absolute;right: 0px;bottom: 0px;}/* 固定定位fixed :相对于视口进行定位 多屏展示*/.box.child.three {background-color: blue;position: fixed;top: 202px;}</style></body></html>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号