Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

break long word around floating image

I am trying to create a page display on mobile. Its layout like this:

/---------\ some text around 
|         | the image. some
|  image  | text around the
|         | image. some text
\---------/ around the image.
some word around the image.
some word around the image.

I use floating style to implement that:

<div style="word-wrap: break-word; word-break: break-all;">
  <img src="someimg.jpg" style="float: left;"/>
  some text around the image. some text around the image. ...
</div>

However, if the word is longer than the right area max length but shorter than the whole div, it won't be break, instead it just be moved below the image.

/---------\ some text around 
|         | the image.
|  image  | 
|         | 
\---------/ 
a-word-longer-than-right will
not be break and just display
below the image while a-word-
longer-than-the-whole-area-wi
ll-be-break-into-next-line

How can I break the word longer than right side and fill the empty area up?

like image 274
TingSong Syu Avatar asked Jul 28 '11 08:07

TingSong Syu


People also ask

How do you break a long word?

The word-wrap property is used to split/break long words and wrap them into the next line. word-break: break-all; It is used to break the words at any character to prevent overflow. word-wrap: break-word; It is used to broken the words at arbitrary points to prevent overflow.

How do you break a long text in CSS?

Breaking long words The word-wrap property is now treated by browsers as an alias of the standard property. An alternative property to try is word-break . This property will break the word at the point it overflows.

How do I make text go around an image in CSS?

What you did here is use the CSS "float" property, which will pull the image from normal document flow (the way that image would normally display, with the text aligned beneath it) and it will align it to the left side of its container. The text that comes after it in the HTML markup with now wrap around it.

How do I put text and pictures side by side?

Here, we create one main div and inside this another div. after this we create a row and we divide the row in two parts with width attribute. After this we specify dimensions to both image and text with float left to align them side by side. This is the basic model to align images and text side by side.


1 Answers

Insert &shy; soft-breaks in the long word. There are various PHP libraries that can do that for you, based on dictionaries.

like image 73
GolezTrol Avatar answered Sep 28 '22 08:09

GolezTrol