min-height CSS property sets the minimum height of an element. It prevents the used value of the height property from becoming smaller than the value specified for min-height .

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

The element's height is set to the value of min-height whenever min-height is larger than max-height or height .

句法

/* <length> value */
min-height: 3.5em;
/* <percentage> value */
min-height: 10%;
/* Keyword values */
min-height: max-content;
min-height: min-content;
min-height: fit-content(20em);
/* Global values */
min-height: inherit;
min-height: initial;
min-height: unset;
				

<length>
Defines the min-height as an absolute value.
<percentage>
Defines the min-height as a percentage of the containing block's height.
auto
The browser will calculate and select a min-height for the specified element.
max-content
The intrinsic preferred min-height .
min-content
The intrinsic minimum min-height .
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, argument )) .

形式定义

初始值 auto
适用于 all elements but non-replaced inline elements, table columns, and column groups
继承 no
百分比 The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as 0 .
计算值 the percentage as specified or the absolute length
动画类型 a length , percentage or calc();

形式句法

auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)

where
<length-percentage> = <length> | <percentage>

范例

Setting min-height

table { min-height: 75%; }
form { min-height: 0; }
					

规范

规范 状态 注释
CSS Box Sizing Module Level 4
The definition of 'min-height' in that specification.
编者草案
CSS Box Sizing Module Level 3
The definition of 'min-height' in that specification.
工作草案 添加 max-content , min-content , fit-content keywords.
CSS Level 2 (Revision 1)
The definition of 'min-height' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
min-height Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 3 注意事项
完整支持 3 注意事项
注意事项 CSS 2.1 leaves the behavior of min-height with table undefined. Firefox supports applying min-height to table elements.
IE 完整支持 7 注意事项
完整支持 7 注意事项
注意事项 In Internet Explorer 10 and 11, a min-height declaration on a column-direction flex container doesn't apply to the container's flex items. See Flexbug #3 for more info.
Opera 完整支持 4 注意事项
完整支持 4 注意事项
注意事项 CSS 2.1 leaves the behavior of min-height with table undefined. Opera supports applying min-height to table elements.
Safari 完整支持 1.3 WebView Android 完整支持 4.4 Chrome Android 完整支持 18 Firefox Android 完整支持 4 注意事项
完整支持 4 注意事项
注意事项 CSS 2.1 leaves the behavior of min-height with table undefined. Firefox supports applying min-height to table elements.
Opera Android 完整支持 14 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0
auto Chrome 完整支持 21 Edge 完整支持 79 Firefox 不支持 16 — 22 注意事项
不支持 16 — 22 注意事项
注意事项 Firefox 18 and later used auto as the initial value for min-height .
IE 不支持 No Opera 完整支持 12.1 Safari 不支持 No WebView Android 完整支持 37 Chrome Android 完整支持 25 Firefox Android 不支持 16 — 22 注意事项
不支持 16 — 22 注意事项
注意事项 Firefox 18 and later used auto as the initial value for min-height .
Opera Android 完整支持 14 Safari iOS 不支持 No Samsung Internet Android 完整支持 1.5
fit-content Experimental Chrome 完整支持 46 Edge 完整支持 79 Firefox 完整支持 3 Prefixed 注意事项
完整支持 3 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -moz-
注意事项 Firefox implements the definitions given in CSS3 Basic Box. This defines available and not fit-available . Also, the definition of fit-content is simpler than in CSS3 Sizing.
IE 不支持 No Opera 完整支持 44 Safari 完整支持 11
完整支持 11
Prefixed Implemented with the vendor prefix: -webkit-
完整支持 2 Alternate Name
Alternate Name Uses the non-standard name: intrinsic
WebView Android 完整支持 46 Chrome Android 完整支持 46 Firefox Android 完整支持 4 Prefixed 注意事项
完整支持 4 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -moz-
注意事项 Firefox implements the definitions given in CSS3 Basic Box. This defines available and not fit-available . Also, the definition of fit-content is simpler than in CSS3 Sizing.
Opera Android 完整支持 43 Safari iOS 完整支持 11
完整支持 11
Prefixed Implemented with the vendor prefix: -webkit-
完整支持 1 Alternate Name
Alternate Name Uses the non-standard name: intrinsic
Samsung Internet Android 完整支持 5.0
max-content Chrome 完整支持 46 Edge 完整支持 79 Firefox 完整支持 66
完整支持 66
完整支持 3 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 不支持 No Opera 完整支持 44 Safari 完整支持 11 WebView Android 完整支持 46 Chrome Android 完整支持 46 Firefox Android 完整支持 66
完整支持 66
完整支持 4 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 43 Safari iOS 完整支持 11 Samsung Internet Android 完整支持 5.0
min-content Chrome 完整支持 46 Edge 完整支持 79 Firefox 完整支持 66
完整支持 66
完整支持 3 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 不支持 No Opera 完整支持 44 Safari 完整支持 11 WebView Android 完整支持 46 Chrome Android 完整支持 46 Firefox Android 完整支持 66
完整支持 66
完整支持 4 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 43 Safari iOS 完整支持 11 Samsung Internet Android 完整支持 5.0
stretch Experimental Chrome 完整支持 28 Alternate Name
完整支持 28 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Edge 完整支持 79 Alternate Name
完整支持 79 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Firefox 不支持 No IE 不支持 No Opera 完整支持 15 Alternate Name
完整支持 15 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Safari 完整支持 9 Alternate Name
完整支持 9 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
WebView Android 完整支持 4.4 Alternate Name
完整支持 4.4 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Chrome Android 完整支持 28 Alternate Name
完整支持 28 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Firefox Android 不支持 No Opera Android 完整支持 15 Alternate Name
完整支持 15 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Safari iOS 完整支持 9 Alternate Name
完整支持 9 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available
Samsung Internet Android 完整支持 1.5 Alternate Name
完整支持 1.5 Alternate Name
Alternate Name Uses the non-standard name: -webkit-fill-available

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

见实现注意事项。

使用非标名称。

使用非标名称。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: