php - 在 CSS 中包裹长文本

标签 php javascript jquery css

<分区>

我有这样的文字

<div style="float:left; width: 250px"> PellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesque  feugiat tempor elit. 
Ut mollis lacinia quam. Sed pharetra, augue aliquam   ornare vestibulum, metus massalaoreet tellus, eget iaculis lacus ipsum et diam. </div>

我不想水平滚动。是否可以换行(自动换行)。我知道有一些 IE 特定的属性。

感谢您的宝贵时间。

更新:我也可以使用 jQuery、Javascript、PHP 来执行此操作。但是怎么办?我的意思是字母(字体)不是固定宽度或任何你称之为的东西。

最佳答案

我用组合

word-wrap: break-word;
overflow: hidden;

来处理这个问题。 word-wrap 设置将允许单词在支持该属性的浏览器中不管它的长度如何被换行,而 overflow 设置将导致它在最后被切断不识别 word-wrap 的浏览器中的可用空间。这与您在不使用 javascript 的情况下可能获得的优雅降级差不多。

关于php - 在 CSS 中包裹长文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1470810/

相关文章:

php - OOP - session 和 PHP

php - 如何以最短的运行时间执行sql select查询

javascript - 获取两个路由器上的 session

javascript - 溢出滚动框左右移动 div

javascript - jQuery UI 对话框和 Textarea 焦点问题

javascript - 如何计算沿(贝塞尔曲线)移动的 1/4 圆弧?

php - Apache 未加载 PHP 扩展

php - php变量中的单引号和双引号

javascript - 表格单元格文本不更新文本内容

php - 具有 "template"功能和 JQuery 和 PHP 视觉帮助的 Dreamweaver 的替代品