父元素没有相对定位也能使自己绝对定位
- 作者: 爱情像杯酒
- 来源: 51数据库
- 2022-08-15
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
html,body{margin: 0; padding:0;}
*{padding:0; margin: 0}
.child{position: absolute; left: 0;top: 0;right: 0; bottom: 0; width: 300px; height: 30px; margin:30px auto; background-color: pink;text-align: center; line-height: 30px;}
</style>
</head>
<body>
<div class="father">
<div class="child">fd</div>
</div>
</body>
</html>
推荐阅读
