CSS hyphens 属性

cssweb developmentfront end technology更新于 2024/11/4 0:44:17

hyphens 属性用于指定文本跨多行换行时单词的连字符方式。该属性具有以下值 −

hyphens: none|manual|auto|initial|inherit;

示例

<!DOCTYPE html>
<html>
<head>
<style>
div {
   width: 50px;
   border: 2px dashed red;
}
.demo {
   -webkit-hyphens: manual;
   -ms-hyphens: manual;
   hyphens: manual;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>hyphens: manual property value</h2>
<div class="demo">This is a demo text.</div>
</body>
</html>

输出

示例

现在让我们看另一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
div {
   width: 50px;
   border: 2px dashed red;
   color: blue;
}
.demo {
   -webkit-hyphens: auto;
   -ms-hyphens: auto;
   hyphens: auto;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>hyphens: auto property value</h2>
<div class="demo">This isssssss a demo text.</div>
</body>
</html>

输出


相关文章


有用资源