Need to center image in web page via CSS

Posted by Robot on Stack Overflow See other posts from Stack Overflow or by Robot
Published on 2010-03-23T17:36:05Z Indexed on 2010/03/23 17:43 UTC
Read the original article Hit count: 612

Filed under:
|
|

I'd like to center an image in a page both vertically and horizontally even when the browser is resized.

Currently, I use this CSS:

.centeredImage {
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -150px;
}

And this HTML:

<img class="centeredImage" src="images/logo.png">

It centers in FF but not IE (image center is placed at upper left corner). Any ideas?

-Robot

© Stack Overflow or respective owner

Related posts about css

Related posts about images