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="" />


Demonstration page:


css-discuss [EMAIL-REMOVED]]
List wiki/FAQ --
Supported by --
Previous Message
Next Message

Message thread: