Max-Height

Utilities for setting the maximum height of an element

Class reference

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

Usage

Set the maximum height of an element using the max-h-full or max-h-screen utilities.

Max-Height - 图1


1. <div class="h-24 ...">
2. <div class="h-48 max-h-full ...">
3. max-h-full
4. </div>
5. </div>


Responsive

To control the max-height of an element at a specific breakpoint, add a {screen}: prefix to any existing max-height utility.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Max-Height - 图2

all

Max-Height - 图3

sm

Max-Height - 图4

md

Max-Height - 图5

lg

Max-Height - 图6

xl


1. <div class="h-24 ...">
2. <div class="h-48 max-h-full sm:max-h-screen md:max-h-full lg:max-h-screen xl:max-h-full ...">
3. <span>Target</span>
4. </div>
5. </div>

Target


Customizing

Max-height scale

Customize Tailwind’s default max-height scale in the theme.maxHeight section of your tailwind.config.js file.


1. // tailwind.config.js
2. module.exports = {
3. theme: {
4. maxHeight: {
5. +       '0': '0',
6. +       '1/4': '25%',
7. +       '1/2': '50%',
8. +       '3/4': '75%',
9. +       'full': '100%',
10. }
11. }
12. }

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

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:


1. // tailwind.config.js
2. module.exports = {
3. variants: {
4. // ...
5. -     maxHeight: ['responsive'],
6. +     maxHeight: ['responsive', 'hover', 'focus'],
7. }
8. }

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:


1. // tailwind.config.js
2. module.exports = {
3. corePlugins: {
4. // ...
5. +     maxHeight: false,
6. }
7. }


← Min-Height   Font Family →