MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

CSS属性 min-height 通常用来设置一个元素的最小高度。这个属性(min-height)不允许一个元素的高度(height)小于这个元素指定的最小高度(min-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;
min-height: fill-available;

/* Global values */
min-height: inherit;
min-height: initial;
min-height: unset;

直译:min-height的值会覆盖max-heightheight。(译者:这句话我的理解是,当该元素的高度小到最小高度的时候,最大高度和高度值将不会有效。)

初始值0
适用元素all elements but non-replaced inline elements, table columns, and column groups
是否是继承属性
PercentagesThe 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.
适用媒体visual
计算值the percentage as specified or the absolute length
Animation typea length, percentage or calc();
正规顺序the unique non-ambiguous order defined by the formal grammar

Syntax

Values

<length>
当最小高度为是一个有具体数值的时候,赋值将会使这个属性的声明无效。
<percentage>
当最小高度是一个本身块级元素高度的百分比的时候,赋值将会使这个属性声明无效。
auto
 auto 是flex元素的默认最小高度,为其他布局提供了更多合理的大于0的默认数值。
max-content
The intrinsic preferred height.
min-content
The intrinsic minimum height.
fill-available
The containing block's height minus horizontal margin, border, and padding. Some browsers implement an ancient name for this keyword, available.
fit-content
According CSS3 Box, this is a synonym of min-content. CSS3 Sizing defines a more complex algorithm, but no browser implements it, even in an experimental way.

Formal syntax

<length> | <percentage> | auto | max-content | min-content | fit-content | fill-available

Examples

table { min-height: 75%; }

form { min-height: 0; }

Specifications

Specification Status Comment
CSS Intrinsic & Extrinsic Sizing Module Level 3
min-height
Working Draft Adds the max-content, min-content, fit-content, and fill-available keywords.
Both CSS3 Box and CSS3 Writing Modes drafts defined at some point these keywords. These drafts are superseded by this spec.
CSS Flexible Box Layout Module
min-height
Candidate Recommendation Added the auto keyword and used it as the initial value.
CSS Transitions
min-height
Working Draft Defines min-height as animatable.
CSS Level 2 (Revision 1)
min-height
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) 3.0 (1.9) 7.0 [3] 4.0 1.0
2.0.2 (416) for positioned elements
applies to <table> [1] 未实现 未实现 (Yes) 未实现 (Yes) 未实现
max-content, min-content, fit-content, and fill-available 未实现 未实现 未实现 未实现 未实现 9
auto已废弃 Gecko 22 21.0 ? 16.0 (16.0) 未实现 12.10 未实现
auto as initial value已废弃 Gecko 22 21.0 ? 18.0 (18.0) 未实现 12.10 未实现
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ? 9

[1] CSS 2.1 explicitly leaves the behavior of min-height with <table> undefined. Therefore any behavior is CSS2.1-compliant; newer CSS specifications may define this behavior, so Web developers shouldn't rely on a specific one now.

[2] Due to bug (bug 307866) Firefox doesn't handle min-height on elements with display: table-*.

[3] In Internet Explorer 10-11 (but not 12+), 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.

See also

文档标签和贡献者

 此页面的贡献者: Huooo
 最后编辑者: Huooo,