Max-Height

Utilities for setting the maximum height of an element

Default class reference

Class Properties
max-h-0 max-height: 0px;
max-h-px max-height: 1px;
max-h-0.5 max-height: 0.125rem;
max-h-1 max-height: 0.25rem;
max-h-1.5 max-height: 0.375rem;
max-h-2 max-height: 0.5rem;
max-h-2.5 max-height: 0.625rem;
max-h-3 max-height: 0.75rem;
max-h-3.5 max-height: 0.875rem;
max-h-4 max-height: 1rem;
max-h-5 max-height: 1.25rem;
max-h-6 max-height: 1.5rem;
max-h-7 max-height: 1.75rem;
max-h-8 max-height: 2rem;
max-h-9 max-height: 2.25rem;
max-h-10 max-height: 2.5rem;
max-h-11 max-height: 2.75rem;
max-h-12 max-height: 3rem;
max-h-14 max-height: 3.5rem;
max-h-16 max-height: 4rem;
max-h-20 max-height: 5rem;
max-h-24 max-height: 6rem;
max-h-28 max-height: 7rem;
max-h-32 max-height: 8rem;
max-h-36 max-height: 9rem;
max-h-40 max-height: 10rem;
max-h-44 max-height: 11rem;
max-h-48 max-height: 12rem;
max-h-52 max-height: 13rem;
max-h-56 max-height: 14rem;
max-h-60 max-height: 15rem;
max-h-64 max-height: 16rem;
max-h-72 max-height: 18rem;
max-h-80 max-height: 20rem;
max-h-96 max-height: 24rem;
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.


1. <div class="h-48 max-h-full md:max-h-screen ...">
2. <span>Target</span>
3. </div>

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


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.

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. extend: {
5. // ...
6. +       maxHeight: ['hover', 'focus'],
7. }
8. }
9. }

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→

Edit this page on GitHub