Skip to content
全部文档

list-style-type

用于控制列表标记样式的工具类。

快速参考

属性
list-disclist-style-type: disc;
list-decimallist-style-type: decimal;
list-nonelist-style-type: none;
list-(<custom-property>)list-style-type: var(<custom-property>);
list-[<value>]list-style-type: <value>;

示例

基础示例

使用 list-disclist-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
<!-- [!code classes:list-disc] -->
<ul class="list-disc">
  <li>Now this is a story all about how, my life got flipped-turned upside down</li>
  <!-- ... -->
</ul>

<!-- [!code classes:list-decimal] -->
<ol class="list-decimal">
  <li>Now this is a story all about how, my life got flipped-turned upside down</li>
  <!-- ... -->
</ol>

<!-- [!code classes:list-none] -->
<ul class="list-none">
  <li>Now this is a story all about how, my life got flipped-turned upside down</li>
  <!-- ... -->
</ul>

使用自定义值

使用 list-[<value>] 等工具类,可根据完全自定义的值设置标记:

html
<ol class="list-[upper-roman] ...">
 <!-- ... -->
</ol>

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

html
<ol class="list-(--my-marker) ...">
 <!-- ... -->
</ol>

这只是 list-[var(<custom-property>)] 的简写,会自动为你加上 var() 函数。

响应式设计

使用 md: 等断点变体前缀,即可让 list-style-type 工具类仅在中等及以上屏幕尺寸下生效:

html
<ul class="list-none md:list-disc ...">
 <!-- ... -->
</ul>

变体文档中了解更多关于使用变体的信息。

文档译文以 MIT 协议授权;原文版权归 Tailwind Labs。湘ICP备2026005453号-2