排版
用于控制列表的项目符号/编号样式的工具。
¥Basic usage
¥Setting the list style type
要创建项目符号列表或数字列表,请使用 list-disc
和 list-decimal
工具。
¥To create bulleted or numeric lists, use the list-disc
and list-decimal
utilities.
<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 lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:list-disc
to only apply the list-disc
utility on hover.
<ul class="list-none hover:list-disc">
<!-- ... -->
</ul>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:list-disc
to apply the list-disc
utility at only medium screen sizes and above.
<ul class="list-none md:list-disc">
<!-- ... -->
</ul>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
¥Using custom values
¥Customizing your theme
默认情况下,Tailwind 为最常见的列表样式类型提供三个工具。你可以通过编辑 Tailwind 配置的 theme.listStyleType
部分来更改、添加或删除它们。
¥By default, Tailwind provides three utilities for the most common list style types. You change, add, or remove these by editing the theme.listStyleType
section of your Tailwind config.
module.exports = {
theme: {
listStyleType: {
none: 'none',
disc: 'disc',
decimal: 'decimal',
square: 'square',
roman: 'upper-roman',
}
}
}
在 主题定制 文档中了解有关自定义默认主题的更多信息。
¥Learn more about customizing the default theme in the theme customization documentation.
¥Arbitrary values
If you need to use a one-off list-style-type
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.
<ul class="list-[upper-roman]">
<!-- ... -->
</ul>
Learn more about arbitrary value support in the arbitrary values documentation.