Text Indent 文本缩进
控制块中文本前显示的空白空间的实用工具。
| Class | Properties |
|---|
基本用法
添加文本缩进
使用 indent-{width} 实用工具来设置在块中显示文本之前显示的空白空间(缩进)的数量。
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. 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 <em>was</em> a marine biologist.
</p>使用负值
要使用负文本缩进值,请在类名前加上破折号,将其转换为负值。
<div class="-indent-8">
So I started to walk into the water. I won't lie to...
</div>有条件地应用
悬停、焦点和其他状态
Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:indent-8 只在悬停时应用 indent-8 实用程序。
<p class="underline hover:indent-8">
<!-- ... -->
</p>有关所有可用状态修改器的完整列表,请查看悬停、焦点和其他状态文档。
断点和媒体查询
您还可以使用变体修饰符来针对响应式断点、深色模式、prefers-reduced-motion 等媒体查询进行定位。例如,使用 md:indent-8 仅在中等屏幕尺寸及以上应用 indent-8 实用程序。
<p class="underline md:indent-8">
<!-- ... -->
</p>要了解更多信息,请查看有关响应式设计、深色模式和其他媒体查询修饰符的文档。
使用自定义值
定制您的主题
默认的文本缩进比例基于默认的间距比例。您可以通过编辑您的 tailwind.config.js 文件中的 theme.spacing 或 theme.extend.spacing 来自定义您的间距比例。
module.exports = {
theme: {
extend: {
spacing: {
'128': '32rem',
},
}
}
}或者,您可以通过编辑您的 tailwind.config.js 文件中的 theme.textIndent 或 theme.extend.textIndent 来自定义文本缩进比例。
module.exports = {
theme: {
extend: {
textIndent: {
'128': '32rem',
},
}
}
}有关自定义默认主题的更多信息,请参阅主题自定义文档。
任意值
如果您需要使用一个与主题无关的 text-indent 值,可以使用方括号来根据任意值动态生成属性。
<p class="indent-[50%]">
<!-- ... -->
</p>有关任意值支持的更多信息,请参阅任意值文档。