word-break 断点换行
word-break属性指定非CJK脚本的断行规则。
提示:CJK脚本是中国,日本和韩国("中日韩")脚本。
语法:
word-break: normal|break-all|keep-all;
break-all:
<style>
.con{
width: 400px;
height: auto;
margin: 50px auto 0;
border: 1px solid skyblue;
/* break-all 允许在单词内换行。*/
word-break: break-all;
}
</style>
</head>
<body>
<div class="con">
When you look around, it’s fairly easy to spot imported products. From foods, electric devices to cars, Chinese people now have more shopping choices thanks to global trade. But this wouldn’t be possible without one organization – the World Trade Organization (WTO).
</div>
</body>
keep-all:
<style>
.con{
width: 400px;
height: auto;
margin: 50px auto 0;
border: 1px solid skyblue;
/* break-all 允许在单词内换行。 */
/* word-break: break-all; */
/*keep-all 只能在半角空格或连字符处换行。 */
word-break: keep-all;
}
</style>
</head>
<body>
<div class="con">
When you look around, it’s fairly easy to spot imported products. From foods, electric devices to cars, Chinese people now have more shopping choices thanks to global trade. But this wouldn’t be possible without one organization – the World Trade Organization (WTO).
</div>
</body>
预览效果图
word-wrap 长内容自动换行
word-wrap属性允许长的内容可以自动换行。
语法:
word-wrap: normal|break-word;
<style>
.con{
width: 400px;
height: auto;
margin: 50px auto 0;
border: 1px solid skyblue;
/* break-word 长内容自动换行*/
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="con">
When you look around, it’s fairly easy to spot importedimportedimportedimportedimportedimportedimportedimported products. From foods, electric devices to cars, Chinese people now have more shopping choices thanks to global trade. But this wouldn’t be possible without one organization – the World Trade Organization (WTO).
</div>
</body>
效果预览图