给个定位 , 再上下左右距离是零就可以实现了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin:0;
padding:0;
}
.father{
width: 900px;
height: 900px;
background-color: #ccc;
margin:0 auto;
padding-top:50px;
}
.son{
height: 300px;
width: 100%;
background-color: pink;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
</style>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
</body>
</html>