- 入门
- 核心概念
- 定制
- Base Styles
- 布局
- Flexbox & Grid
- Flex Basis
- Flex Direction
- Flex Wrap
- Flex
- Flex Grow
- Flex Shrink
- Order
- Grid Template Columns
- Grid Column Start / End
- Grid Template Rows
- Grid Row Start / End
- Grid Auto Flow
- Grid Auto Columns
- Grid Auto Rows
- Gap
- Justify Content
- Justify Items
- Justify Self
- Align Content
- Align Items
- Align Self
- Place Content
- Place Items
- Place Self
- 间隔
- 尺寸
- 排版
- Font Family
- Font Size
- Font Smoothing
- Font Style
- Font Weight
- Font Variant Numeric
- Letter Spacing
- Line Clamp
- Line Height
- List Style Image
- List Style Position
- List Style Type
- Text Align
- Text Color
- Text Decoration
- Text Decoration Color
- Text Decoration Style
- Text Decoration Thickness
- Text Underline Offset
- Text Transform
- Text Overflow
- Text Wrap
- Text Indent
- Vertical Align
- Whitespace
- Word Break
- Hyphens
- Content
- 背景
- 边框
- Effects
- Filters
- 表格 Tables
- Transitions & Animation
- Transforms
- Interactivity
- SVG
- Accessibility
- 其他
- Install Tailwind CSS using PostCSS
- Framework Guides
- Try Tailwind CSS using the Play CDN
- Install Tailwind CSS with Next.js
- Install Tailwind CSS with Laravel
- Install Tailwind CSS with Vite
- Install Tailwind CSS with Nuxt
- Install Tailwind CSS with Gatsby
- Install Tailwind CSS with SolidJS
- Install Tailwind CSS with SvelteKit
- Install Tailwind CSS with Angular
- Install Tailwind CSS with Ruby on Rails
- Install Tailwind CSS with Remix
- Install Tailwind CSS with Phoenix
- Install Tailwind CSS with Parcel
- Install Tailwind CSS with Symfony
- Install Tailwind CSS with Meteor
- Install Tailwind CSS with Create React App
- Install Tailwind CSS with Adonis
- Install Tailwind CSS With Ember.js
- Install Tailwind CSS with Astro
- Install Tailwind CSS with Qwik
- Install Tailwind CSS with Rspack
Text Indent
Utilities for controlling the amount of empty space shown before text in a block.
Quick reference
Class | Properties |
---|---|
indent-0 | text-indent: 0px; |
indent-px | text-indent: 1px; |
indent-0.5 | text-indent: 0.125rem; /* 2px */ |
indent-1 | text-indent: 0.25rem; /* 4px */ |
indent-1.5 | text-indent: 0.375rem; /* 6px */ |
indent-2 | text-indent: 0.5rem; /* 8px */ |
indent-2.5 | text-indent: 0.625rem; /* 10px */ |
indent-3 | text-indent: 0.75rem; /* 12px */ |
indent-3.5 | text-indent: 0.875rem; /* 14px */ |
indent-4 | text-indent: 1rem; /* 16px */ |
indent-5 | text-indent: 1.25rem; /* 20px */ |
indent-6 | text-indent: 1.5rem; /* 24px */ |
indent-7 | text-indent: 1.75rem; /* 28px */ |
indent-8 | text-indent: 2rem; /* 32px */ |
indent-9 | text-indent: 2.25rem; /* 36px */ |
indent-10 | text-indent: 2.5rem; /* 40px */ |
indent-11 | text-indent: 2.75rem; /* 44px */ |
indent-12 | text-indent: 3rem; /* 48px */ |
indent-14 | text-indent: 3.5rem; /* 56px */ |
indent-16 | text-indent: 4rem; /* 64px */ |
indent-20 | text-indent: 5rem; /* 80px */ |
indent-24 | text-indent: 6rem; /* 96px */ |
indent-28 | text-indent: 7rem; /* 112px */ |
indent-32 | text-indent: 8rem; /* 128px */ |
indent-36 | text-indent: 9rem; /* 144px */ |
indent-40 | text-indent: 10rem; /* 160px */ |
indent-44 | text-indent: 11rem; /* 176px */ |
indent-48 | text-indent: 12rem; /* 192px */ |
indent-52 | text-indent: 13rem; /* 208px */ |
indent-56 | text-indent: 14rem; /* 224px */ |
indent-60 | text-indent: 15rem; /* 240px */ |
indent-64 | text-indent: 16rem; /* 256px */ |
indent-72 | text-indent: 18rem; /* 288px */ |
indent-80 | text-indent: 20rem; /* 320px */ |
indent-96 | text-indent: 24rem; /* 384px */ |
Basic usage
Adding a text indent
Use the indent-*
utilities 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. 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>
Using negative values
To use a negative text indent value, prefix the class name with a dash to convert it to a negative value.
<div class="-indent-8">
So I started to walk into the water. I won't lie to...
</div>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:indent-8
to only apply the indent-8
utility on hover.
<div class="indent-4 hover:indent-8">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:indent-8
to apply the indent-8
utility at only medium screen sizes and above.
<div class="indent-4 md:indent-8">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
Using custom values
Customizing your theme
The default text indent scale is based on the default spacing scale. You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
spacing: {
'128': '32rem',
}
}
}
}
Alternatively, you can customize just the text indent scale by editing theme.textIndent
or theme.extend.textIndent
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
textIndent: {
'128': '32rem',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
Arbitrary values
If you need to use a one-off text-indent
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="indent-[50%]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论