1: Through the Position:absolute positioning, the upper and lower values are set to 0,margin:auto; need to know the height of the div
{
width:64px;
height:64px;
border:1px solid red;
Position:absolute;
top:0;
left:0;
bottom:0;
right:0;
Margin:auto;
}
2: Need to know the width of the div, by positioning the width of the moving page half of the position, and then through the Margin-top and margin-left the width of the div to move the general can be achieved;
{
width:64px;
height:64px;
border:1px solid red;
Background-image:url (img/g2.gif);
background-size:100% 100%;
Position:absolute;
top:50%;
left:50%;
Margin-top: -32px;
Margin-left: -32px;
}
3 Unknown div width height. To be propped up by the contents of a Div
{
border:1px solid red;
Position:absolute;
top:50%;
left:50%;
-webkit-transform:translate (-50%,-50%);
-moz-transform:translate (-50%,-50%);
-ms-transform:translate (-50%,-50%);
-o-transform:translate (-50%,-50%);
Transform:translate (-50%,-50%);
}
About a div up and down centered CSS method