使用 CSS 实现文本缩进

cssweb developmentfront end technology更新于 2024/11/29 3:56:17

要实现文本缩进,请使用 CSS 中的 text-indent 属性。该属性用于段落首行的缩进。

示例

现在来看一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
div {
   text-indent: 30px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
</div>
</body>
</html>

输出

示例

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

<!DOCTYPE html>
<html>
<head>
<style>
div {
   text-indent: 15em;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
</div>
</body>
</html>

输出


相关文章


有用资源