How to align text below in <p> with <img>?

This is the code. I want to align the text below

<p style="background:#eee;font-size:1.3em;color:#022662;height:116px"> <img width="174" height="116" src="#" style="margin-right:10px;float:left"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </p> 

added example for checking http://jsbin.com/ubiji/2

+4
source share
4 answers

Your question is incomprehensible, but maybe you want the text to act as a block and have a "text 3" part, built with the image?

If so, this should work:

  <p style="background:#eee;font-size:1.3em;color:#022662;height:116px;"> <img width="174" height="116" src="#" style="margin-right:10px; vertical-align:bottom"> <span style="display:inline-block; background: #ff6; vertical-align:bottom"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </span> </p> 
+7
source

There must be a simple solution for this. This is not true.

Some of them talk about vertical alignment: text-bottom or just vertical-align: bottom. Like this:

 <p style="background:#eee;font-size:1.3em;color:#022662;height:116px;"> <img width="174" height="216" src="#" style="vertical-align:bottom;margin-right:10px;"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </p> 

This works the way you plan if you have only one line of text, as this is the first line of text aligned with the image. This is because, by default, <img / ">: inline; is displayed. If you have only one line, go for it.

If you need a more reliable solution, use positioning.

 <p style="background:#eee;font-size:1.3em;color:#022662;height:116px;position:relative;"> <img width="174" height="216" src="#" style="margin-right:10px;"> <span style="position:absolute;bottom: 0;"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </span> </p> 

This works in IE7 standards mode and in IE8 standard. Also in Firefox, etc. Please note that the left position is not specified, by default it should be out of position: absolute;

Due to the fact that hasLayout is not true in Quirks mode in IE6, 7 and 8, the solution does not work. You must give it a "layout", giving it a measurement with height or width, or simply return to the old faithful zoom: 1;

 <p style="background:#eee;font-size:1.3em;color:#022662;height:116px;position:relative;zoom:1"> <img width="174" height="216" src="#" style="margin-right:10px;"> <span style="position:absolute;bottom: 0;"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </span> </p> 

There you have it.

+1
source
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>TITLE</title> </head> <body> <p>Here is your text <img src="penseur.gif" width="70" height="137" align="bottom" alt="penseur"> at the bottom</p> </body> </html> 
0
source

Could vertical-align be what you are looking for?

http://www.w3schools.com/css/pr_pos_vertical-align.asp

 <p style="background:#eee;font-size:1.3em;color:#022662;height:116p""> <img width="174" height="116" src="#" style="margin-right:10px;float:left"> <div style="vertical-align:text-bottom"> <strong>Text 1</strong>, <br> text 2, <br> text 3 </div> </p> 

I need a div, I think.

0
source

Source: https://habr.com/ru/post/1305009/


All Articles