For most browsers you can use position:fixed
img.centered {
position:fixed;
left: 50%;
top: 50%;
margin-left: -32px;
margin-top: -32px;
}
If the image was, for example, 40x30 pixels, you would set margin-left:-20px; margin-top:-15px.
Here is a jsfiddle example: http://jsfiddle.net/WnSnj/1/
Please note that the position: fixed does not work exactly the same in all browsers (although this is normal in all modern browsers). See: http://www.quirksmode.org/css/position.html
source
share