Today I learned a very practical css as follows:
div{
width: 600px;
height: 60px;
background: #13ce66;
position: absolute;
left: 50%;
top: 0;
margin-left: -300px; /*组件真实宽度的一半 这里是600的一半*/
}
Recorded as a formula, it is left: 50%; margin-left: half of the negative width.