html – 如何限制文本宽度

前端之家收集整理的这篇文章主要介绍了html – 如何限制文本宽度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想限制一个文本块的宽度,因此它将看起来像每行的ned都有br。

这样的事情

Texttttttttttttttttttttt
tttttttttttttttttttttttt
tttttttttttttttttttttttt

由此:

Texttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

我试图指定div或p的宽度,但对我来说并不奏效。有什么建议么?

解决方法

你可以这样应用css:
div {
   word-wrap: break-word;
   width: 100px;
}

通常浏览器不会打破单词,而是单词:break-word;也会强迫它打破话语。

演示:http://jsfiddle.net/Mp7tc/

更多关于word-wrap的信息

原文链接:https://www.f2er.com/html/233262.html

猜你在找的HTML相关文章