div{
position: relative;
width: 400px;
height: 400px;
border: 1px solid #000;
}
img{
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}