打破长行句的方法

Mac*_*Mac 7 html css iphone word-wrap

我正在为我的网站开发一个iPhone主题,你能否打破这样的长句:

A long sentence would go past the iPhone screen and I need this to break
Run Code Online (Sandbox Code Playgroud)

进入:

A long sentence would go past the iPhone
screen and I need this to break
Run Code Online (Sandbox Code Playgroud)

显示如下:

http://uimgz.com/i/M8U5X5f2d1.png

Fab*_*ook 9

根据:https://developer.mozilla.org/en-US/docs/Web/CSS/white-space#Browser_compatibility

pre {
  word-wrap: break-word;      /* IE 5.5-7 */
  white-space: -moz-pre-wrap; /* Firefox 1.0-2.0 */
  white-space: pre-wrap;      /* current browsers */
}
Run Code Online (Sandbox Code Playgroud)

word-wrap似乎不再起作用,white-space改为使用


Sot*_*ris 8

如果您的文本有空格,则为wrap元素添加宽度将自动中断文本.但是如果你有一个没有空格的文本(例如链接),你可以使用break-word:

.your-selector {
  word-wrap: break-word;
}
Run Code Online (Sandbox Code Playgroud)