List Style Type 列表样式类型
控制列表项目的项目符号/编号样式的实用工具。
| Class | Properties |
|---|
基本用法
设置列表样式类型
要创建项目符号或数字列表,请使用 list-disc 和 list-decimal 实用工具。
list-disc
- Now this is a story all about how, my life got flipped-turned upside down
- And I'd like to take a minute just sit right there
- I'll tell you how I became the prince of a town called Bel-Air
list-decimal
- Now this is a story all about how, my life got flipped-turned upside down
- And I'd like to take a minute just sit right there
- I'll tell you how I became the prince of a town called Bel-Air
list-none
- Now this is a story all about how, my life got flipped-turned upside down
- And I'd like to take a minute just sit right there
- I'll tell you how I became the prince of a town called Bel-Air
html
<ul class="list-disc">
<li>Now this is a story all about how, my life got flipped-turned upside down</li>
<!-- ... -->
</ul>
<ol class="list-decimal">
<li>Now this is a story all about how, my life got flipped-turned upside down</li>
<!-- ... -->
</ol>
<ul class="list-none">
<li>Now this is a story all about how, my life got flipped-turned upside down</li>
<!-- ... -->
</ul>有条件地应用
悬停、焦点和其他状态
Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:list-disc 仅在悬停时应用 list-disc 实用程序。
html
<p class="list-none hover:list-disc">
<!-- ... -->
</p>有关所有可用状态修改器的完整列表,请查看悬停、焦点和其他状态文档。
断点和媒体查询
您还可以使用变体修饰符来针对响应式断点、深色模式、prefers-reduced-motion 等媒体查询进行定位。例如,使用 md:list-disc 仅在中等屏幕尺寸及以上应用 list-disc 实用程序。
html
<p class="list-none md:list-disc">
<!-- ... -->
</p>要了解更多信息,请查看有关响应式设计、深色模式和其他媒体查询修饰符的文档。
使用自定义值
定制您的主题
默认情况下,Tailwind 只提供了 list-image-none 实用工具。您可以通过编辑您的 tailwind.config.js 文件中的 theme.listStyleImage 或 theme.extend.listStyleImage 来自定义这些值。
js
module.exports = {
theme: {
listStyleType: {
none: 'none',
disc: 'disc',
decimal: 'decimal',
square: 'square',
roman: 'upper-roman',
}
}
}有关自定义默认主题的更多信息,请参阅主题自定义文档。
任意值
如果您需要使用一个与主题无关的 list-style-type 值,可以使用方括号来根据任意值动态生成属性。
html
<p class="list-[upper-roman]">
<!-- ... -->
</p>有关任意值支持的更多信息,请参阅任意值文档。