绝对定位(HTML、CSS)

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>绝对定位</title>
<style>
.granfather {

position: relative;
/* 此时son盒子遵循的是granfather盒子 */
width: 800px;
height: 800px;
background-color: green;
padding: 50px;
}

.father {
/* 如果在大盒子中加相对定位 则son盒子永远在father盒子里边 */
/* position: relative; */
width: 500px;
height: 500px;
background-color: blue;
}

.son {
position: absolute;
/* top: 0;
left: 0; */
/* top: 100px;
right: 200px; */
left: 0;
bottom: 0;
width: 200px;
height: 200px;
background-color: skyblue;
}
</style>
</head>

<body>
<div class="granfather">
<div class="father">
<div class="son"></div>
</div>

</div>

</body>

</html>