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,
Johnwhat kind of image is it?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,
JohnIf 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.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..Put the image in as the background for the div and you can fiddle its alignment all you want.
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,
Johnwhat kind of image is it?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,
JohnIf 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.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..Put the image in as the background for the div and you can fiddle its alignment all you want.