发布网友 发布时间:2022-04-23 10:44
共1个回答
热心网友 时间:2022-04-20 23:41
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{margin: 0;padding: 0;}
.div1{width: 500px;height: 300px;background-color: #c2c2c2;position: relative;}
.div2{width: 180px;height: 230px;background-color: #fff; position: absolute;left: 50px;top: 30px;}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div class="div1">
<div class="div2">这是上面div</div>
</div>
</body>
</html>
在主容器里面设置绝对定位,absolute就会以他对齐