使用 CSS tab-size 属性设置 HTML 中的制表符大小

cssweb developmentfront end technology更新于 2024/8/29 19:24:17

CSS tab-size 属性 允许我们设置制表符中使用的空白量。以下示例演示了 CSS tab-size 属性。

示例

<!DOCTYPE html>
<html>
<head>
<style>
body {
   display: flex;
   flex-direction: column;
}
p {
   white-space: pre;
}
p:last-of-type {
   tab-size: 32;
   -moz-tab-size: 32;
}
</style>
</head>
<body>
<p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p>
<p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p>
</body>
</html>

输出

这将产生以下结果 −

示例

<!DOCTYPE html>
<html>
<head>
<style>
pre {
   margin: 2%;
   box-shadow: inset 0 0 12px lime;
}
p {
   background: lavender;
   tab-size: 1;
   -moz-tab-size: 1;
}
</style>
</head>
<body>
<pre>
4 tabs of size 1 paragraph
.|.|.|.
<p>
Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.
</p>
</pre>
</body>
</html>

输出

这将产生以下结果 −


相关文章


有用资源