Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

float fluid image left with out text wrapping

There is no reason this should be difficult to achieve. Back in the way day you could just create a table and put the image on the first cell and the text on the second. Easy as pie.

For some reason I am having a hell of a time getting this to work with css, and I know css pretty fluently. I'm sure I'm just overlooking a hopefully easy answer.

What I'm looking to achieve:

  • Dynamic sized (being pulled from database) image floated to the left - Description text to the right with out wrapping below image when it reaches the image height.

What won't work:

  • Setting a margin-left on the text (width of image is not consistent)
  • Setting a width / floating right on text (again, image width is dynamic so proper width on text would be unknown)

Example Code (pre css):

<div class="demo">
    <img src="dynamic_sized_image.jpg" />
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>

Hopefully there is an answer!!

Thank you!

like image 866
rkingon Avatar asked Sep 21 '11 05:09

rkingon


People also ask

How do I stop text wrapping around an image in HTML?

You'll have to wrap your text in its own container. Since your <img> is floated to the left, you can use overflow: hidden on your newly-added container to achieve no wrapping of the text.

How do I stop text wrapping in CSS?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).


1 Answers

Here is solution for your issue ( p { overflow: hidden} )

http://jsfiddle.net/simoncereska/BnQRW/

like image 173
simoncereska Avatar answered Sep 30 '22 19:09

simoncereska