Vertically align images in a div
I'm pretty confident when it comes to HTML and CSS but I cant for the life of me work out how to Vertically align images in a div.
I need to vertically align them in the middle.
The reason being is that the images are inserted dynamically, all of them have the same width but the height is variable therefore affecting the overall look.
1. margin-top:auto; & margin-bottom:auto;
Any other ideas would be appreciated!
Last edited by jc_gmk; 07-19-2007 at 08:33 AM.
You would think it would be simple, but vertical-align doesn't work the way most would expect it to, unless the element is in a table. You could simply add a table in the area in which you want to display the image and set the style for the td as vertical-align:middle.
There are also various workarounds if you want to avoid the use of tables.
Two good ones are: