<style>
#div{
width: 800px;
height: 500px;
border: 1px solid gold;
position: relative;
}
#div1{
width: 200px;
height: 200px;
background-color: cyan;
position: absolute; /*父元素需要相对定位*/
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
</style>
<body>
<div id="div">
<div id="div1"></div>
</div>
</body>