2 replies [Last post]
cssgern
cssgern's picture
Offline
newbie
Last seen: 1 year 1 week ago
Timezone: GMT+1
Joined: 2006-05-08
Posts: 10
Points: 0

quick beginner's question

what is the best way to vertically and horizontally center an img within a div? I've tried using text-align and vertical-align, but they don't seem to be having any effect.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 16 weeks 1 day ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

[Solved] img alignment

The simplest way, since IE does not support css2, is to use a single celled table. See the demo, http://garyblue.port5.com/webdev/vcenter2.html

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

cssgern
cssgern's picture
Offline
newbie
Last seen: 1 year 1 week ago
Timezone: GMT+1
Joined: 2006-05-08
Posts: 10
Points: 0

[Solved] img alignment

That did the trick. Cheers, Gary