<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.grandfather {
position: relative;
width: 800px;
height: 800px;
background-color: red;
}
.father {
width: 500px;
height: 500px;
background-color: skyblue;
}
.son {
position: absolute;
width: 200px;
height: 200px;
left: 30px;
bottom: 10px;
background-color: pink;
}
/* 绝对定位特点:
1.如果没有祖先元素或祖先元素没有定位,则以浏览器为准定位 */
/* 2.如果祖先元素有定位(相对,绝对,固定定位)则以最近一级有定位元素为参考点移动位置 */
/* 3.绝对定位不在占有原来位置 */
</style>
</head>
<body>
<div class="grandfather">
<div class="father">
<div class="son">
</div>
</div>
</div>
</div>
</body>
</html>