The height
border area.
The height
border area.
height: 150px;
height: 6em;
height: 75%;
height: auto;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
This is a box where you can change the height.
</div>
</section>
#example-element {
display: flex;
flex-direction: column;
background-color: #5b6dcd;
justify-content: center;
color: #ffffff;
}
The max-height
properties override height
.
Note:
As a geometric property, height
also applies to the <foreignObject>
SVG elements, with auto
resolving to 0
and percent values being relative to the SVG viewport height for <rect>
. The CSS height
property value overrides any SVG height
attribute value set on the SVG element.
/* <length> values */
height: 120px;
height: 10em;
height: 100vh;
height: anchor-size(height);
height: anchor-size(--myAnchor self-block, 250px);
height: clamp(200px, anchor-size(width));
/* <percentage> value */
height: 75%;
/* Keyword values */
height: max-content;
height: min-content;
height: fit-content;
height: fit-content(20em);
height: auto;
height: stretch;
/* Global values */
height: inherit;
height: initial;
height: revert;
height: revert-layer;
height: unset;
<length>
Defines the height as a distance value.
<percentage>
Defines the height as a percentage of the containing block's height.
auto
The browser will calculate and select a height for the specified element.
max-content
The intrinsic preferred height.
min-content
The intrinsic minimum height.
fit-content
Use the available space, but not more than max-content, i.e. min(max-content, max(min-content, stretch))
.
fit-content(<length-percentage>
)
Uses the fit-content formula with the available space replaced by the specified argument, i.e. min(max-content, max(min-content, <length-percentage>))
.
stretch
Sets the height of the element's box-sizing.
Note:
To check aliases used by browsers for the stretch
value and its implementation status, see the Browser compatibility section.
Ensure that elements set with a height
aren't truncated and/or don't obscure other content when the page is zoomed to increase text size.
Animation type | a | min-content | <anchor-size()> <length-percentage> = [ <anchor-name> ? ) <calc-size-basis> = | <calc-sum> <calc-sum> = <calc-product> ] <calc-product> | height | self-inline <calc-product> = <calc-value> ] <calc-value> | | <calc-keyword> | -infinity | NaN ExamplesSetting height using pixels and percentagesHTMLhtml
CSScss
ResultSpecifications
Browser compatibilityBCD tables only load in the browser See also |
---|