<html>
<style>
.div1{width:300px;height:300px;background:green;margin: auto;position:absolute;left:0;right:0;top:0;bottom:0;}
</style>
<body>
<div class="div1"></div>
</body>
</html>
绝对定位的div居中
最新推荐文章于 2023-08-13 00:34:20 发布
<html>
<style>
.div1{width:300px;height:300px;background:green;margin: auto;position:absolute;left:0;right:0;top:0;bottom:0;}
</style>
<body>
<div class="div1"></div>
</body>
</html>