简体   繁体   中英

Display multi-line text and image on the same row in CSS

How do you do that? For example, if my text is too long, it should auto-wrap but the entire text should still be on the same row as the image. Something like:

+------+
|image | text, text, text
|      | and more text
+------+

Is it possible? I tried:

 <img src="http://placehold.it/100" /><span style = "display:inline">text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text and more text</span> 

But all it does is to wrap the exceeding text to the row below both the image and the text.

Thanks! Sorry if my explanation is not clear, as I cannot post images.

You can achieve this by adding float:left to the elements ( both img and text ).

Code:

<img style="float:left" src = "image.png" />
<span style = "float:left">text, text, text and more text</span>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM