1. 弹性盒 & 网格
  2. 排序

Quick reference

Class
Properties
order-1order: 1;
order-2order: 2;
order-3order: 3;
order-4order: 4;
order-5order: 5;
order-6order: 6;
order-7order: 7;
order-8order: 8;
order-9order: 9;
order-10order: 10;
order-11order: 11;
order-12order: 12;
order-firstorder: -9999;
order-lastorder: 9999;
order-noneorder: 0;

基本用法

¥Basic usage

排序弹性和网格项目

¥Ordering flex and grid items

使用 order-* 工具以与 DOM 中出现的顺序不同的顺序渲染 Flex 和网格项。

¥Use the order-* utilities to render flex and grid items in a different order than they appear in the DOM.

01
02
03
<div class="flex justify-between ...">
  <div class="order-last">01</div>
  <div>02</div>
  <div>03</div>
</div>

使用负值

¥Using negative values

要使用负顺序值,请在类名前加上破折号以将其转换为负值。

¥To use a negative order value, prefix the class name with a dash to convert it to a negative value.

<div class="-order-1">
  <!-- ... -->
</div>

有条件地应用

悬停、聚焦和其他状态

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

<div class="order-first hover:order-last">
  <!-- ... -->
</div>

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:order-last to apply the order-last utility at only medium screen sizes and above.

<div class="order-first md:order-last">
  <!-- ... -->
</div>

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


使用自定义值

¥Using custom values

自定义主题

¥Customizing your theme

默认情况下,Tailwind 提供 order-firstorder-lastorder-none 的工具以及编号为 1 到 12 的工具。你可以通过编辑 tailwind.config.js 文件中的 theme.ordertheme.extend.order 来自定义这些值。

¥By default, Tailwind provides utilities for order-first, order-last, order-none, and numbered utilities from 1 through 12. You can customize these values by editing theme.order or theme.extend.order in your tailwind.config.js file.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      order: {
        '13': '13'
      }
    }
  }
}

主题定制 文档中了解有关自定义默认主题的更多信息。

¥Learn more about customizing the default theme in the theme customization documentation.

任意值

¥Arbitrary values

If you need to use a one-off order 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="order-[13]">
  <!-- ... -->
</div>

Learn more about arbitrary value support in the arbitrary values documentation.