打破长字或句子 [英] Breaking a long Word or Sentence
本文介绍了打破长字或句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用与浏览器无关的CSS来断断续续?
我正在使用"word-break:normal/break-all/hyphenate;" css来打破较长的句子,这在Mozila firefox或Opera上不起作用.
或如何编写长单词的JavaScript?
How can I break a long word using CSS which is browser independent?
I am using "word-break:normal/break-all/hyphenate;" css for breaking a long Sentence Which does not work on Mozila firefox or Opera.
or How to write a javascript which break a long word?
推荐答案
您可以尝试将word-break
与word-wrap
组合使用
像这样的东西:
You could try theword-break
in combination withword-wrap
Something like:
.MyClass
{
word-wrap: break-word;
word-break: hyphenate;
}
这在我在IE,FF,Chrome,Opera和Safari中的测试中起作用:
This worked in my test in IE, FF, Chrome, Opera and Safari:
<html>
<head>
<title>wrapping test</title>
</head>
<body>
<div style="width: 60px; word-wrap: break-word; word-break: hyphenate;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Antidisestablishmentarianism.
</div>
</body>
</html>
您可以包括自动换行属性以换行并在下一行显示内容.您只需要将此属性添加为STYLE ="word-wrap:break-word"即可.
You can include the word wrap property to break the line and display the content on next line. You have to just include this property as STYLE="word-wrap: break-word" .
这篇关于打破长字或句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文