If you want an object to always be in the center of the screen, regardless of the other elements, then you should use position: fixed
, anchor it at the ends of the screen, use a fixed size and margem: auto
:
.centro {
background-image: url('http://cdn.flaticon.com/png/256/42608.png');
box-shadow: 0px 0px 10px black;
border-radius: 50%;
background-color: whitesmoke;
width: 256px;
height: 256px;
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
margin: auto;
}
<div class="centro"></div>
If it forms alterative to margin: auto
, you can use transform: traslate(-50%, -50%)
to move the element.
.centro {
background-image: url('http://cdn.flaticon.com/png/256/42608.png');
box-shadow: 0px 0px 10px black;
border-radius: 50%;
background-color: whitesmoke;
width: 256px;
height: 256px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
<div class="centro"></div>