How to: vertically center (align) text after an image in the same <div> ??

2,905 views
Skip to first unread message

Govinda

unread,
Apr 22, 2009, 9:16:09 PM4/22/09
to Web Authoring
Hi all

I have a <div> with an image in it with this style:

style="vertical-align:middle; margin-top:5px;

within the same <div>, immediately after the image, I have 3 words of
text which I want to be vertically aligned so that that string appears
vertically centered with respect to the image. I have been fiddling
with this css for an hour, and I am such a css clutz that I figured I
better end the frustration and actually ask for someone's help who can
do this in 3 seconds. Thanks for any input!

-Govinda

klan...@gmail.com

unread,
Apr 23, 2009, 1:10:38 AM4/23/09
to web-au...@googlegroups.com
govinda.w...@gmail.com (Govinda) wrote on 4/22/09 6:16 PM

I am sure someone will correct me if I am wrong but I do not
believe there is a reliable way to do what you want to do
without some IE hacking. vertical-align works nicely within
table cells but not in divs, mostly because the height of the
text content is unknown.

Here is one solution you might look at for ideas:

http://www.jakpsatweb.cz/css/css-vertical-center-solution.html

Ken

--
Simple Lives Web Design
http://simplelives.com

Reply all
Reply to author
Forward
0 new messages