Max-Height

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

Class reference

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

用法

利用 max-h-fullmax-h-screen 工具类设置页面元素的最大高度。

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

响应式

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

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

Target
Target
Target
Target
Target

定制

Max-height 比例

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

// tailwind.config.js
module.exports = {
theme: {
maxHeight: {
+     '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 max-height utilities.

You can control which variants are generated for the max-height utilities by modifying the maxHeight 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: {
    // ...
-   maxHeight: ['responsive'],
+   maxHeight: ['responsive', 'hover', 'focus'],
}
}

Disabling

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

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