Previous Message
Next Message

How to vertically center img in div?

Sent by Bob McClelland on 21 September 2004 20:08


----- Original Message ----- 
From: "Roger Martin" [EMAIL-REMOVED]>
To: [EMAIL-REMOVED]>
Sent: Tuesday, September 21, 2004 7:15 PM
Subject: [css-d] How to vertically center img in div?


> 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
>

Try http://www.bugimus.com/gurus/center_div.html, (CSS plus javascript)  but
you'll have to 'view source' to see how to do it (legal, and encouraged by
the author, incidentally).

Bob

______________________________________________________________________
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: