1.margin: auto method:
html:
<div>
<img src="mm.jpg">
</div>
css:
div{
width:400px;
height:400px;
position:relative;
border:1px solid #465468;
}
img{
position:absolute;
margin:auto;
top:0;
left:0;
right:0;
bottom:0;
}
Up and down is positioned 0, margin: 0 may be implemented centrally from the document stream
2.margin negative law
.container{
width:500px;
height:500px;
border: 2px solid #379;
position:relative;
}
,inner{
width:480px;
height:480px;
background-color:#746;
position:absolute;
top:50%;
left:50%;
margin-top:-190px;
margin-left:-240px;
}
May be replaced by a negative value
transform:translateX(-50%)
transform:translateY(-50%)