是可以的。但是,前提是这两个DIV在同一个窗口中,且不能浮动。
以下是和结果图
<html >
<head>
<title>无标题文档</title>
<style type="text/css">
#id1{
width:200px;height:100px;
background:red;
position:relative;/*父级相对定位*/
top: -20px;
}
#id2 {
background-color: #009933;
}
</style>
</head>
<body>
<div id="id1">ggg
</div>
<div id="id2">ggg
</div>
</body>
</html>
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/0e2442a7d933c89567479935d11373f082020046?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)