1. 排版
  2. text-indent

排版

text-indent

用于控制块中文本前显示的空白空间量的工具。

样式
indent-<number>
text-indent: calc(var(--spacing) * <number>)
-indent-<number>
text-indent: calc(var(--spacing) * -<number>)
indent-px
text-indent: 1px;
-indent-px
text-indent: -1px;
indent-(<custom-property>)
text-indent: var(<custom-property>);
indent-[<value>]
text-indent: <value>;

示例(Examples)

¥Examples

基本示例(Basic example)

¥Basic example

使用 indent-<number> 工具(如 indent-2indent-8)设置块中文本前显示的空白空间(缩进)量:

¥Use indent-<number> utilities like indent-2 and indent-8 to set the amount of empty space (indentation) that's shown before text in a block:

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

<p class="indent-8">So I started to walk into the water...</p>

使用负值(Using negative values)

¥Using negative values

要使用负文本缩进值,请在类名前加上破折号以将其转换为负值:

¥To use a negative text indent value, prefix the class name with a dash to convert it to a negative value:

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

<p class="-indent-8">So I started to walk into the water...</p>

使用自定义值(Using a custom value)

¥Using a custom value

使用 indent-[<value>] 语法 根据完全自定义的值设置 text indentation

<p class="indent-[50%] ...">
<!-- ... -->
</p>

对于 CSS 变量,还可以使用 indent-(<custom-property>) 语法:

<p class="indent-(--my-indentation) ...">
<!-- ... -->
</p>

这只是简写,用于 indent-[var(<custom-property>)] 它会自动为你添加 var() 函数。

响应式设计(Responsive design)

¥Responsive design

text-indent 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:

<p class="indent-4 md:indent-8 ...">
<!-- ... -->
</p>

请参阅 变体文档 详细了解如何使用变体。

TailwindCSS v4.0 中文网 - 粤ICP备13048890号