批改状态:未批改
老师批语:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>1.相对定位</title>
<style type="text/css">
.box1 {
width: 200px;
height: 200px;
background-color: lightskyblue;
/*相对定位*/
position: relative;
top: 0;
left: 200px;
}
.box2 {
width: 200px;
height: 200px;
background-color: lightgreen;
/*相对定位*/
position: relative;
top: 200px;
left: 200px;
}
.box3 {
width: 200px;
height: 200px;
background-color: lightcoral;
/*相对定位*/
position: relative;
top: -200px;
left: 0px;
}
.box4 {
width: 200px;
height: 200px;
background-color: brown;
/*相对定位*/
position: relative;
top: -400px;
left: 400px;
}
</style>
</head>
<body><!--
定位:
四种模式:static,relative,absolute,fixed;
四个位置:left,right,top,bottom;
相对定位:元素相对于她原来在文档流中的位置进行定位 -->
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号