在CSS中包装长文本 [英] Wrapping long text in 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屋!