Min-Height

用于设置页面元素的最小高度的工具类

Class reference

Class Properties
.min-h-0 min-height: 0;
.min-h-full min-height: 100%;
.min-h-screen min-height: 100vh;

用法

利用 min-h-0min-h-fullmin-h-screen 工具类设置页面元素的最小高度。

min-h-full
<div class="h-48 ...">
  <div class="h-24 min-h-full ...">
    min-h-full
  </div>
</div>

响应式

如需控制页面元素在特定断点处的最小高度,请在现有的 min-height 工具类的前面添加 {screen}: 前缀。

进一步了解 Tailwind 的响应式设计功能,请参阅 响应式设计 章节。

Target
Target
Target
Target
Target

定制

Min-height 比例

tailwind.config.js 配置文件中的 theme.minHeight 配置段可以定制 Tailwind 的默认 min-height 比例。

// tailwind.config.js
module.exports = {
theme: {
minHeight: {
+     '0': '0',
+     '1/4': '25%',
+     '1/2': '50%',
+     '3/4': '75%',
+     'full': '100%',
}
}
}

前往 定制主题 章节进一步了解定制默认主题的详细信息。

Responsive and pseudo-class variants

By default, only responsive variants are generated for min-height utilities.

You can control which variants are generated for the min-height utilities by modifying the minHeight property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

// tailwind.config.js
module.exports = {
variants: {
    // ...
-   minHeight: ['responsive'],
+   minHeight: ['responsive', 'hover', 'focus'],
}
}

Disabling

If you don't plan to use the min-height utilities in your project, you can disable them entirely by setting the minHeight property to false in the corePlugins section of your config file:

// tailwind.config.js
module.exports = {
corePlugins: {
    // ...
+   minHeight: false,
}
}