效果图
relative在父级元素设置,absulate在子元素设置才有想象中的效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.bi1 {
width: 100%;
height: 500px;
}
.big2 {
width: 1190px;
height: 500px;
position: relative;
margin: 0 auto;
}
.zishang {
background-color: #C5E0B4;
position: absolute;
top: 80px;
width: 80px;
height: 43px;
}
.zixia {
display: inline-block;
background-color: #62C292;
top: 90px;
}
</style>
<body>
<div class="big1" style='background-color:#F8CBAD;padding-top:10px;'>祖先元素
<div class="big2" style='background-color:#FFE699;border:10px solid white;padding-top:10px;'>父级元素
<div class="zishang">子元素(上)</div>
<div class="zixia">子元素(下)</div>
</div>
</div>
</body>
</html>