Click to See Complete Forum and Search --> : vertical-align for img


jasnjohn
12-07-2003, 07:55 AM
Is there anyway to vertically align an image and centre it in a <div>?

My div style is as follows;

div.img {position:absolute; top:110px; left:220px; width:350px; height:300px; background-color:#F0F0F0; align:center; vertical-align:middle}

I just want the image to be placed bang in the middle of the div.

Thanks,
John

Vladdy
12-07-2003, 08:11 AM
what kind of image is it?

jasnjohn
12-07-2003, 08:17 AM
OK, the div is 350px across, and 300px high.
The image is just a 72dpi JPEG photo.
Some photos in the div will be landscape and others portrait, so I wanted them to always be smack in the middle of the div.

Cheers,
John

Vladdy
12-07-2003, 08:47 AM
If your div size is fixed and the image size is known - use margins to position the image.
Also, if images would qualify as a presentational element rather than content, it would be easier to put them as element background.

jasnjohn
12-07-2003, 08:55 AM
Thanks for the help.
I'll have to settle for use of margins as the images will change frequently as they're part of a gallery.

thanks again..

ray326
12-07-2003, 12:08 PM
Put the image in as the background for the div and you can fiddle its alignment all you want.