Previous Message
Next Message

How to vertically center img in div?

Sent by Roger Martin on 21 September 2004 19:07


How can I vertically center an image in a div? I know I could hard code
margin top and bottom values, but in my case I never know the exact size of
the image, so I need to "automate" the centering, much like margin:auto
works to horizontally align things.

<div style="width:300px;height:300px;">

<img src="..." style="width:100px;height:100px;" alt="" />

</div>

Demonstration page: http://www.techinfosystems.com/centerimgindiv.htm

Cheers!
Roger


______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: