Log in

View Full Version : vertical align of paragraph to image problem



the_dinesh
03-12-2011, 05:34 PM
dear seniors...

i need some help in vertical alignment of text. i have one div within which there is
first one image
then text (say h1)
and another image in last.

i have this kind of css with html:

<div>
<img src="1.jpg" style="float:left;"/>
<p style="float:left;">here goes text which need to be in middle vertically</p>
<img src="2.jpg" style="float:left;"/>
<div style="clear:both;">
</div>
</div>

and my images are big in height so it is showing that text are in top with the level of image which i want to be in the middle i.e. vertically in middle.

plz help me senior, how would i be able to do that? i am sorry for my poor english.. if you dont understand this then plz see picture which i have attached here.

plz help me.

djr33
03-12-2011, 06:25 PM
Does this help?


<div>
<img src="1.jpg" style="float:left;"/>
<p>here goes text which need to be in middle vertically</p>
<img src="2.jpg" style="float:right;"/>
<div style="clear:both;">
</div>
</div>

What you need is vertical-align:middle; but it is difficult to do.
This page might help:
http://www.student.oulu.fi/~laurirai/www/css/middle/
You can also search google for more information.


The easiest way I have found to do this is to use a table. In a <td> vertical-align usually works. It's not the best way to make a page, but it's the easiest way that I know to do what you are asking for. Someone else may have a better answer.