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]>
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
> 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:
> Cheers!
> Roger

Try, (CSS plus javascript)  but
you'll have to 'view source' to see how to do it (legal, and encouraged by
the author, incidentally).


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

Message thread: