1. 尺寸
  2. 最小高度

Quick reference

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

基本用法

¥Basic usage

设置最小高度

¥Setting the minimum height

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

¥Set the minimum height of an element using min-h-* utilities.

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

有条件地应用

悬停、聚焦和其他状态

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

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

<div class="h-24 min-h-0 md:min-h-full">
  <!-- ... -->
</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 height scale is a combination of the default spacing scale as well as some additional values specific to heights.

你可以通过编辑 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-height,请使用 tailwind.config.js 文件的 theme.minHeight 部分。

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

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      minHeight: {
        '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-height 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-h-[220px]">
  <!-- ... -->
</div>

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