1. 排版
  2. 列表样式位置

Quick reference

Class
Properties
list-insidelist-style-position: inside;
list-outsidelist-style-position: outside;

基本用法

¥Basic usage

设置列表样式位置

¥Setting the list style position

使用 list-insidelist-outside 工具来控制列表中标记和文本缩进的位置。

¥Use the list-inside and list-outside utilities to control the position of the markers and text indentation in a list.

list-inside

  • 5 cups chopped Porcini mushrooms
  • 1/2 cup of olive oil
  • 3lb of celery

list-outside

  • 5 cups chopped Porcini mushrooms
  • 1/2 cup of olive oil
  • 3lb of celery
<ul class="list-inside ...">
  <li>5 cups chopped Porcini mushrooms</li>
  <!-- ... -->
</ul>

<ul class="list-outside ...">
  <li>5 cups chopped Porcini mushrooms</li>
  <!-- ... -->
</ul>

有条件地应用

悬停、聚焦和其他状态

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:list-inside to only apply the list-inside utility on hover.

<ul class="list-outside hover:list-inside">
  <!-- ... -->
</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-inside to apply the list-inside utility at only medium screen sizes and above.

<ul class="list-outside md:list-inside">
  <!-- ... -->
</ul>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.