CSS3 word-break 属性
在合适的点换行:
p.test {word-break:break-all;}
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
属性 | |||||
---|---|---|---|---|---|
word-break | 4.0 | 5.5 | 15.0 | 3.1 | 15.0 |
word-break属性指定非CJK脚本的断行规则。
提示:CJK脚本是中国,日本和韩国("中日韩")脚本。
值 | |
---|---|
默认值: | normal |
继承: | yes |
版本: | CSS3 |
JavaScript 语法: | object.style.wordBreak="break-all" |
语法
word-break: normal|break-all|keep-all;
实例
<style>
p.demo-word-break1
{
width:9em;
border:1px solid #000000;
word-break:keep-all;
}
p.demo-word-break2
{
width:9em;
border:1px solid #000000;
word-break:break-all;
}
</style>
<p class="demo-word-break1"> This paragraph contains some text. This line will-break-at-hyphenates.</p>
<p class="demo-word-break2"> This paragraph contains some text: The lines will break at any character.</p>
效果
keep-all
This paragraph contains some text. This line will-break-at-hyphenates.
break-all
This paragraph contains some text: The lines will break at any character.
normal
This paragraph contains some text: The lines will break at any character.
属性值
值 | 描述 |
---|---|
normal | 使用浏览器默认的换行规则。 |
break-all | 允许在单词内换行。 |
keep-all | 只能在半角空格或连字符处换行。 |