一、使用position
CSS
<style>
html, body {
width: 100%;
height: 100%;
overflow: hidden;
background: #EEEEEE;
}
.box {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
margin: auto;
width: 100px;
height: 100px;
background:lightblue;
}
</style>
HTML
<body>
<div class="box"></div>
</body>