Sizing
Utilities for setting the maximum height of an element.
Class | Styles |
---|---|
max-h-<number> | max-height: calc(var(--spacing) * <number>); |
max-h-<fraction> | max-height: calc(<fraction> * 100%); |
max-h-auto | max-height: auto; |
max-h-px | max-height: 1px; |
max-h-full | max-height: 100%; |
max-h-screen | max-height: 100vh; |
max-h-dvh | max-height: 100dvh; |
max-h-dvw | max-height: 100dvw; |
max-h-lvh | max-height: 100lvh; |
max-h-lvw | max-height: 100lvw; |
max-h-svh | max-height: 100svh; |
max-h-svw | max-height: 100svw; |
max-h-min | max-height: min-content; |
max-h-max | max-height: max-content; |
max-h-fit | max-height: fit-content; |
max-h-(<custom-property>) | max-height: var(<custom-property>); |
max-h-[<value>] | max-height: <value>; |
Use max-h-<number>
utilities like max-h-24
and max-h-64
to set an element to a fixed maximum height based on the spacing scale:
Use max-h-full
and max-h-<fraction>
utilities like max-h-1/2
and max-h-2/5
to give an element a percentage-based maximum height:
Use the max-h-[<value>]
syntax to set the maximum height based on a completely custom value:
<div class="max-h-[220px] ..."> <!-- ... --></div>
For CSS variables, you can also use the max-h-(<custom-property>)
syntax:
<div class="max-h-(--my-max-height) ..."> <!-- ... --></div>
This is just a shorthand for max-h-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a max-height
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="h-48 max-h-full md:max-h-screen ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.
The max-h-<number>
utilities are driven by the --spacing
theme variable, which can be customized in your own theme:
@theme { --spacing: 1px; }
Learn more about customizing the spacing scale in the theme variable documentation.