CSS line-break 属性在确定如何分隔文本块中的行时非常有用。这是必不可少的,因为它使页面更易读和可读。
可能的值
- auto:应用默认换行规则。
- loose:应用限制最少的换行规则。
- normal:应用最常见的换行规则。
- strict:应用最严格的换行规则。
- anywhere:允许浏览器在任何地方、任何字符处应用换行规则。
- initial:设置初始值。
- inherit:继承父元素的值。
适用于
所有 HTML 元素。
DOM 语法
object.style.lineBreak = "strict";
例
下面是一个示例:
<html>
<head>
<style>
p {
border: 2px solid blue;
width: 200px;
}
.normal {
line-break: normal;
}
.loose {
line-break: loose;
}
.strict {
line-break: strict;
}
.auto {
line-break: auto;
}
.anywhere {
line-break: anywhere;
}
</style>
</head>
<body>
<h2>Line Break</h2>
<p class="normal">Normal - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text.</p>
<p class="loose">Loose - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
<p class="strict">Strict - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
<p class="auto">Auto - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
<p class="anywhere">Anywhere - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
</body>
</html>