"Alexey Smirnov" <> wrote in message
news:7980c8c4-8994-43d0-9db0-...
On Jun 29, 3:07 am, "AAaron123" <aaaron...@roadrunner.com> wrote:
> Guess I found my problem.
>
> img {vertical-align: middle}
> Places the image in the middle of the baseline.
>
> But knowing doesn't help.
>
> <div><img></img></div>
>
> How do I get the img to center vertically in the div?
>
> Where is the baseline?
>
> Thanks
There are few ways you can try. The easiest way is to set line-height
for the div element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<div style="height:300px;border:solid 1px red;line-height:300px"><img
style="vertical-align:middle;" src="http://groups.google.se/intl/en/
images/logos/groups_logo.gif"></div>
</body>
</html>
This method does not work nicely at all if image is higher than
container.
See more at
http://www.student.oulu.fi/~laurirai/www/css/middle/
I used "middle" to set vertical-align because the baseline is the
"line" upon which a line of text rests (Characters such as g or p
extend down below the baseline). Change my example to baseline and you
will see that the image goes up a little.
Hope this helps
========
I just copied your div and stuck it in my code and got a red rectangle with
"Google groups" at the top of the rectangle.
So I made a new web form and inserted your entire code into it and again got
"Google groups" not centered vertically.
Tried in IE8 and Firefox.
I noticed the site you referenced did not give code for using line-height so
I assume you wrote it and tried it.
Your comment about using baseline instead of middle make me think you ran it
and "Google groups" was centered vertically. Is that correct?
Thanks a lot
PS he also had this but no reference to Firefox, IE7 or IE8
Opera 7.51p1, 8b3; Mozilla 1.4.1; FF1; Konqueror 3.1.4-6; MacIE5; Safari
1.1.1 Works
IE5.5; IE6; Opera 6 Text centering works