三、绝对定位
绝对定位比相对定位更灵活。(相对于(0,0)点)
*{
margin: 0;
padding: 0;
}
div{
width: 200px;
height: 200px;
}
.box1{
background-color: yellowgreen;
}
.box2{
background-color: skyblue;
position: absolute;
top: 100px;
left: 140px;
}
.box3{
background-color: gold;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 200px;
height: 200px;
}
.box1 {
background: yellowgreen;
}
.box2 {
background: skyblue;
position: absolute;
top: 100px;
left: 140px;
}
.box3 {
background: orange;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>
***相应效果