1. 尺寸
  2. 最小宽度

Quick reference

Class
Properties
min-w-0min-width: 0px;
min-w-1min-width: 0.25rem; /* 4px */
min-w-2min-width: 0.5rem; /* 8px */
min-w-3min-width: 0.75rem; /* 12px */
min-w-4min-width: 1rem; /* 16px */
min-w-5min-width: 1.25rem; /* 20px */
min-w-6min-width: 1.5rem; /* 24px */
min-w-7min-width: 1.75rem; /* 28px */
min-w-8min-width: 2rem; /* 32px */
min-w-9min-width: 2.25rem; /* 36px */
min-w-10min-width: 2.5rem; /* 40px */
min-w-11min-width: 2.75rem; /* 44px */
min-w-12min-width: 3rem; /* 48px */
min-w-14min-width: 3.5rem; /* 56px */
min-w-16min-width: 4rem; /* 64px */
min-w-20min-width: 5rem; /* 80px */
min-w-24min-width: 6rem; /* 96px */
min-w-28min-width: 7rem; /* 112px */
min-w-32min-width: 8rem; /* 128px */
min-w-36min-width: 9rem; /* 144px */
min-w-40min-width: 10rem; /* 160px */
min-w-44min-width: 11rem; /* 176px */
min-w-48min-width: 12rem; /* 192px */
min-w-52min-width: 13rem; /* 208px */
min-w-56min-width: 14rem; /* 224px */
min-w-60min-width: 15rem; /* 240px */
min-w-64min-width: 16rem; /* 256px */
min-w-72min-width: 18rem; /* 288px */
min-w-80min-width: 20rem; /* 320px */
min-w-96min-width: 24rem; /* 384px */
min-w-pxmin-width: 1px;
min-w-0.5min-width: 0.125rem; /* 2px */
min-w-1.5min-width: 0.375rem; /* 6px */
min-w-2.5min-width: 0.625rem; /* 10px */
min-w-3.5min-width: 0.875rem; /* 14px */
min-w-fullmin-width: 100%;
min-w-minmin-width: min-content;
min-w-maxmin-width: max-content;
min-w-fitmin-width: fit-content;

基本用法

¥Basic usage

设置最小宽度

¥Setting the minimum width

使用 min-w-* 工具设置元素的最小宽度。

¥Set the minimum width of an element using min-w-* utilities.

min-w-80
min-w-64
min-w-48
min-w-40
min-w-32
min-w-24
min-w-full
<div class="w-96 ...">
  <div class="min-w-80 ...">min-w-80</div>
  <div class="min-w-64 ...">min-w-64</div>
  <div class="min-w-48 ...">min-w-48</div>
  <div class="min-w-40 ...">min-w-40</div>
  <div class="min-w-32 ...">min-w-32</div>
  <div class="min-w-24 ...">min-w-24</div>
  <div class="min-w-full ...">min-w-full</div>
</div>

有条件地应用

悬停、聚焦和其他状态

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

<div class="w-24 min-w-full hover:min-w-0">
  <!-- ... -->
</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:min-w-0 to apply the min-w-0 utility at only medium screen sizes and above.

<div class="w-24 min-w-full md:min-w-0">
  <!-- ... -->
</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 的最小宽度比例是 默认间距比例 以及一些特定于宽度的附加值的组合。

¥By default, Tailwind’s minimum width scale is a combination of the default spacing scale as well as some additional values specific to widths.

你可以通过编辑 tailwind.config.js 文件中的 theme.spacingtheme.extend.spacing 来自定义间距比例。

¥You can customize your spacing scale by editing theme.spacing or theme.extend.spacing in your tailwind.config.js file.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      spacing: {
        '128': '32rem',
      }
    }
  }
}

要单独自定义 min-width,请使用 tailwind.config.js 文件的 theme.minWidth 部分。

¥To customize min-width separately, use the theme.minWidth section of your tailwind.config.js file.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      minWidth: {
        '128': '32rem',
      }
    }
  }
}

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

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

任意值

¥Arbitrary values

If you need to use a one-off min-width 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="min-w-[220px]">
  <!-- ... -->
</div>

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