如何在JavaScript中为非CJK脚本设置换行规则?
在JavaScript中使用wordbreak属性可为非CJK脚本设置换行规则。以下是CJK脚本:C代表中文,J代表日语,K代表朝鲜语。
示例
您可以尝试运行以下代码以了解如何实现wordbreak属性-
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 150px;
height: 120px;
background-color: lightblue;
border: 1px solid black;
}
</style>
</head>
<body>
<button onclick = "display()">Set</button>
<div id = "box">
This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.
</div>
<script>
function display() {
document.getElementById("box").style.wordBreak = "break-all";
}
</script>
</body>
</html>热门推荐
10 美好的成语祝福语简短
11 喜事作文结尾祝福语简短
12 中考祝福语简短古风短句
13 儿媳买车妈妈祝福语简短
14 疫情五一快乐祝福语简短
15 分手毕业祝福语简短女生
16 姑娘生日祝福语简短的话
17 牛年祝福语简短100句
18 老师订婚文案祝福语简短