第一种(未知大小)
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
第二种(已知大小)
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
第三种(使用transform)
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top: 50%;
left: 50%;
transform:translate(-50%,-50%)