<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.a1,.a2,.a3{
width: 100px;
height: 100px;
}
.a1{
background-color: palegreen;
}
.a2{
background-color: palevioletred;
position: relative;
top: -100px;
left: 100px;
}
.a3{
background-color: peru;
}
.b1,.b2,.b3{
width: 100px;
height: 100px;
}
.b1{
background-color: palegreen;
}
.b2{
background-color: pink;
position: relative;
}
.b3{
background-color: peru;
}.b4{
width: 50px;
height: 50px;
background-color: palevioletred;
position: absolute;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<!-- 相对定位 position:relative -->
<h2>相对定位</h2>
<div class="a1">1</div>
<div class="a2">2</div>
<div class="a3">3</div>
<br>
<!-- ****************************************************** -->
<!-- 绝对定位 position: -->
<h2>绝对定位</h2>
<div class="b1">1</div>
<div class="b2">2
<div class="b4">4</div>
</div>
<div class="b3">3</div>
<br>
<!-- ****************************************************** -->
<!-- 固定定位 -->
<!-- ****************************************************** -->
<!-- 粘滞定位 -->
</body>
</html>
转载请注明原文地址:https://ipadbbs.8miu.com/read-20303.html