css - 打破 float 图像周围的长词

标签 css css-float word-wrap

我正在尝试创建一个在移动设备上显示的页面。它的布局是这样的:

/---------\ 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.

我使用 float 样式来实现:

<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>

但是,如果单词长于右侧区域的最大长度但短于整个div,则不会被打断,而只是被移动到图像下方。

/---------\ 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

如何打断比右侧长的单词并填充空白区域?

最佳答案

在长词中插入 ­ 软中断。有各种基于字典的 PHP 库可以为您做到这一点。

关于css - 打破 float 图像周围的长词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6855979/

相关文章:

javascript - 加倍这个修改后的 bootstrap 4 旋转木马只能正确运行一半(滚动循环停止工作)

CSS 边框不衬图像

php - 围绕 php 循环包装 div

javascript - 如何在 data-win-bind 中设置 ID?

html - 如何添加独立于其他单元格的表格单元格?

css - 向左浮动导致悬停在菜单右侧

css - 确保 float :right element is vertically aligned to the top, 即使在 float:left 元素旁边

html - 让我的 div 环绕另一个 div?

css - 文字换行 [CSS]

html - 避免在响应式设计中使用 Meta Viewport 标签 - Google Insights Score