在CSS中包装长文本 [英] Wrapping long text in CSS

查看:122
本文介绍了在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特定的属性。

I do not want horizontal scrolling. Is it possible to wrap the text (auto-line break). I know there are some IE specific properties.

感谢您的时间。

更新:我可以使用jQuery,Javascript,PHP 。但如何?

UPDATE: I can use jQuery, Javascript, PHP to do this also. but how? I mean the letters (font) are not fixed width or whatever you call that.

推荐答案

我使用组合

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

word-wrap 设置将允许该字被包装,尽管它在支持该属性的浏览器中的长度,而 overflow 设置将导致它在浏览器中不能识别 word-wrap 的可用空间结尾处被切断。这是关于作为优雅的降级,你可能会得到,而不去javascript。

to deal with this. The word-wrap setting will allow the word to be wrapped despite its length in browsers which support that property, while the overflow setting will cause it to be cut off at the end of the available space in browsers which don't recognize word-wrap. That's about as graceful of degradation as you're likely to get without going to javascript.

这篇关于在CSS中包装长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆