使用 CSS 设置字母间距
cssweb developmentfront end technology更新于 2024/11/4 2:20:17
要设置字母(即字符)之间的间距,请使用 letter-spacing 属性。以下是属性值 −
letter-spacing: normal|length|initial|inherit;
示例
<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
letter-spacing: 1px;
}
p.demo2 {
letter-spacing: 10px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>
输出

示例
现在让我们看另一个例子 −
<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
letter-spacing: 1cm;
}
p.demo2 {
letter-spacing: -2px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>
输出

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

