How to force a really long word to stay on the same line as an image?

FiZiX

I'd like to force the text of a really long word to stay on the same line as my image. I know the word will need to wrap but I'd like the first line to stay aligned with the image instead of the first line jumping to the line after the image. My layout needs to be dynamic so setting a static width or height for the text is out of the question. Here's my code:

HTML:

<img class='inline-img' src='design/dislike.png'/>
<p class='inline-text'>LotsoftextLotsoftextLotsoftextLotsoftextLotsoftextLotsoftextLotsoftextLotsoftextLotsoftextLotsoftext</p>

CSS:

img.inline-img { height: 24px; width: 24px; margin-right: 4px; float:left; }
p.inline-text { color:#F00; word-wrap:break-word; display: inline;}

Fiddle: http://jsfiddle.net/JvFAw/

UPDATE: I may put the image in the background of a parent DIV and use a margin to offset the text from the image unless somebody can suggest something more elegant

UPDATE2: Made a real world example as recommended by paulie_d

http://jsfiddle.net/JvFAw/4/

FiZiX

For lack of a more elegant solution, I think I'll do this:

HTML:

<div class="container">
    <p class='inline-text'>antidisestablishmentarianismism</p>
</div>

CSS:

div.container {
    max-width: 211.5px;
    background: url(http://www.geoengineer.org/templates/rt_voxel/images/icons/icon-home.png) no-repeat left top;
    padding-left: 20px;
}
p.inline-text {
    color:#F00;
    word-wrap:break-word;
    font-size: 18px;
}

Fiddle: http://jsfiddle.net/JvFAw/7/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Force image to stay on the same line as text

From Dev

Force image to stay on the same line as text

From Java

How to force a line break in a long word in a DIV?

From Dev

How do I force an input to stay on the same line as its label with Bootstrap form-control class?

From Dev

How do I force an input to stay on the same line as its label with Bootstrap form-control class?

From Dev

How to ensure two words stay on the same line?

From Dev

Force next word to a new line if the word is too long for the textview

From Dev

How to force tkinter text widget to stay on one line

From Dev

How do I force all ul elements to stay in one line?

From Dev

Awk (or other) how to force the field number to stay the same?

From Dev

How to keep two dynamic divs on same line and force to word wrap on right

From Dev

Keep last word and image on same line

From Dev

How to force Word to recompute image numbers?

From Dev

How to make text overflow horizontally (stay on same line)

From Dev

How can I align my buttons so that they stay in the same line?

From Dev

how to make sure two inline elements stay on the same line

From Dev

On jquery fadeIn, how can i make it such that they will stay on the same line?

From Dev

How to make background image position stay same on all resolutions?

From Dev

How to force images to be aligned in the same line?

From Dev

How to force button and select on the same line?

From Dev

Force Navbar elements to stay in one line

From Dev

Force Xamarin Studio view layout to stay the same

From Dev

Text and image in <button> won't stay on same line using flexbox in Firefox

From Dev

Force divs to be on the same line

From Dev

How can I force break word in same length?

From Dev

How can I force break word in same length?

From Dev

How to align image same as text in Word 2007?

From Dev

How to force a CONFIG_ option to stay on?

From Dev

How to Force Aero Peek to Stay Up

Related Related

  1. 1

    Force image to stay on the same line as text

  2. 2

    Force image to stay on the same line as text

  3. 3

    How to force a line break in a long word in a DIV?

  4. 4

    How do I force an input to stay on the same line as its label with Bootstrap form-control class?

  5. 5

    How do I force an input to stay on the same line as its label with Bootstrap form-control class?

  6. 6

    How to ensure two words stay on the same line?

  7. 7

    Force next word to a new line if the word is too long for the textview

  8. 8

    How to force tkinter text widget to stay on one line

  9. 9

    How do I force all ul elements to stay in one line?

  10. 10

    Awk (or other) how to force the field number to stay the same?

  11. 11

    How to keep two dynamic divs on same line and force to word wrap on right

  12. 12

    Keep last word and image on same line

  13. 13

    How to force Word to recompute image numbers?

  14. 14

    How to make text overflow horizontally (stay on same line)

  15. 15

    How can I align my buttons so that they stay in the same line?

  16. 16

    how to make sure two inline elements stay on the same line

  17. 17

    On jquery fadeIn, how can i make it such that they will stay on the same line?

  18. 18

    How to make background image position stay same on all resolutions?

  19. 19

    How to force images to be aligned in the same line?

  20. 20

    How to force button and select on the same line?

  21. 21

    Force Navbar elements to stay in one line

  22. 22

    Force Xamarin Studio view layout to stay the same

  23. 23

    Text and image in <button> won't stay on same line using flexbox in Firefox

  24. 24

    Force divs to be on the same line

  25. 25

    How can I force break word in same length?

  26. 26

    How can I force break word in same length?

  27. 27

    How to align image same as text in Word 2007?

  28. 28

    How to force a CONFIG_ option to stay on?

  29. 29

    How to Force Aero Peek to Stay Up

HotTag

Archive