Vetical and Horizontally Align an image in a box

Posted by Rhyso on Stack Overflow See other posts from Stack Overflow or by Rhyso
Published on 2010-05-18T11:38:04Z Indexed on 2010/05/18 11:40 UTC
Read the original article Hit count: 146

The problem:

I have a set width and height image Lets say height:160px; width:200px; with an image in each box.

The image can vary in size but I need a solution that will always center the image vertically and horizontally within the box no matter what it's size.

Horizontal doesn't seem to be a problem by using margin: 0 auto but vertical is proving difficult. I have tried vertical align: center but this doesnt appear to work either

Any help is appriciated Thanks

© Stack Overflow or respective owner

Related posts about css-positioning

Related posts about vertical-alignment