CSS hyphenate-character 属性允许您指定在使用 hyphens 属性连字符文本时应用作连字符点的字符。
当文本被连字符时,浏览器将在单词内的适当位置插入连字符,以改善对齐文本的视觉外观。hyphenate-character 属性允许您自定义用于连字的字符。
可能的值
- <string> - 它用作 <string> 在连字符断开之前行的末尾。
- auto − 默认值。用户代理根据内容语言的排版约定确定合适的字符串。需要显式设置才能覆盖继承的值。
适用于
所有元素。
语法
hyphenate-character: <string> | auto;
它允许将特定字符串替换为连字符,并指示用户代理根据排版约定(默认)选择合适的字符串。
CSS hyphenate-character - 自动值
以下示例演示了 hyphenate-character: auto 属性允许在指定元素的内容中自动连字 -
<html>
<head>
<style>
div {
width: 80px;
border: 2px solid blue;
hyphens: auto;
hyphenate-character: auto;
}
</style>
</head>
<body>
<div>CSS hyphenatecharacter auto</div>
</body>
</html>
CSS hyphenate-character - <string> 值
以下示例演示了 hyphenate-character 属性,不同的连字符表示连字符行为的不同效果 -
<html>
<head>
<style>
div {
width: 80px;
border: 2px solid blue;
hyphens: auto;
}
.box1 {
hyphenate-character: "=";
}
.box2 {
hyphenate-character: "*";
}
.box3 {
hyphenate-character: "%";
}
</style>
</head>
<body>
<h3>hyphenate-character: "="</h3>
<div class="box1">CSS hyphenatecharacter auto</div>
<h3>hyphenate-character: "*"</h3>
<div class="box2">CSS hyphenatecharacter auto</div>
<h3>hyphenate-character: "%"</h3>
<div class="box3">CSS hyphenatecharacter auto</div>
</body>
</html>