尺寸
高度height
Setting an element’s height.
Overview
| Class | Declarations |
|---|---|
h:full | height: 100%;
|
h:fit | height: fit-content;
|
h:min | height: min-content;
|
h:max | height: max-content;
|
h:3xs | height: var(--container-3xs);
|
h:2xs | height: var(--container-2xs);
|
h:xs | height: var(--container-xs);
|
h:sm | height: var(--container-sm);
|
h:md | height: var(--container-md);
|
h:lg | height: var(--container-lg);
|
h:xl | height: var(--container-xl);
|
h:2xl | height: var(--container-2xl);
|
h:3xl | height: var(--container-3xl);
|
h:4xl | height: var(--container-4xl);
|
h:5xl | height: var(--container-5xl);
|
h:6xl | height: var(--container-6xl);
|
h:7xl | height: var(--container-7xl);
|
h:<size> | height: <size>;
|
Examples
Set a fixed height
Use h:* to set the CSS height property. Fixed heights are best for controls, media frames, skeletons, and areas with intentionally bounded content.
<div class="h:12x bg:gray-5"> ...</div>Generated CSS
@layer utilities { .h\:12x { height: 3rem }}Fill a parent height
Use h:full when the parent has a definite height.
<section class="h:64x"> <div class="h:full">...</div></section>If the parent height is automatic, percentage heights such as h:full and h:50% may not resolve the way you expect. This is native CSS behavior.
Use viewport and intrinsic values
Use native CSS units for viewport-sized regions, and keywords when the content should define the block size.
<main class="min-h:100dvh">...</main><aside class="h:fit">...</aside>Size both axes together
For square icons, avatars, and controls, prefer size over repeating w:* and h:*.
<button class="size:10x round">...</button>Apply conditionally
Apply styles based on different states using selectors and conditional queries.
<div class="h:10x:hover h:14x@sm h:full@dark h:auto@print">...</div>Use min-height when content may grow but the region still needs a baseline size.