Skip to content
Related Articles

Related Articles

Improve Article

Tailwind CSS Max-Height

  • Last Updated : 16 Feb, 2021

This class accepts lots of values in tailwind CSS in which all the properties are covered in class form.  It is the alternative to the CSS Max-Height property. This class is used to set the maximum height of an element. If the content of the element is larger than the specified maximum-height then the content will overflow otherwise it has no effect. If the content of the element is smaller than it has no effect. The height class value can be overridden by the max-height class.

Max-Height classes:

  • max-h-0
  • max-h-px
  • max-h-full
  • max-h-screen

Note: You can change the number with the valid “rem” values.

max-h-0: This class is used to set the maximum specific height for any element.

Syntax:



<element class="max-h-0">...</element>

Example:

HTML




<!DOCTYPE html> 
<head
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"
</head
  
<body class="text-center mx-4 space-y-2"
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1
    <b>Tailwind CSS Max-Height Class</b
    <div class="mx-48 h-24 bg-green-200 p-8">
        <div class="max-h-0 bg-green-400 
                    rounded-lg">max-h-0</div>
    </div>
</body
  
</html>

Output:

max-h-px:  This class is used to set the 1px specific height for any element.

Syntax:

<element class="max-h-px">...</element>

Example:

HTML




<!DOCTYPE html> 
<head
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"
</head
  
<body class="text-center mx-4 space-y-2"
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1
    <b>Tailwind CSS Max-Height Class</b
    <div class="mx-48 h-24 bg-green-200 p-8">
        <div class="max-h-px bg-green-400 
                    rounded-lg">max-h-px</div>
    </div>
</body
  
</html>

Output:



max-h-full: This class is used to set the maximum height of an element that is full, depending on the parent element.

Syntax:

<element class="max-h-full">...</element>

Example:

HTML




<!DOCTYPE html> 
<head
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"
</head
  
<body class="text-center mx-4 space-y-2"
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1
    <b>Tailwind CSS Max-Height Class</b
    <div class="mx-48 h-24 bg-green-200 p-8">
        <div class="h-48 max-h-full bg-green-400 
                    rounded-lg">max-h-full</div>
    </div>
</body
  
</html>

Output:

max-h-screen: This class is used to make an element span the entire height of the viewport to the maximum. To control the max-height of an element at a specific breakpoint, add a “screen” prefix to any existing max-height utility.

Syntax:

<element class="max-h-screen">...</element>

Example:

HTML




<!DOCTYPE html> 
<head
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"
</head
  
<body class="text-center mx-4 space-y-2"
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1
    <b>Tailwind CSS Max-Height Class</b
    <div class="mx-48 h-48 bg-green-200 p-8">
        <div class="max-h-screen bg-green-400 
                    rounded-lg">max-h-screen</div>
    </div>
</body
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :