if you want an object to stay always in the center of the screen, regardless of other elements, then you must 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>
in an amending form to margin: auto
, you can use a 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>
This answer solves your question about positioning your image?
– David