Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

min-height

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

概述

min-height属性用来设置给定元素的最小高度。如果height属性设置的高度比该属性设置的高度还小,则height属性会失效。

min-height会把max-height和 height的值都覆盖掉。

初始值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

语法

/* <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;

<length>
一个固定的最小高度. 查看<length>了解可用的长度单位。
<percentage>
<percentage>值是根据包含该元素的父元素的高度计算得来的,如果该元素的父元素没有明确的指定高度,则该百分比相当于0。
auto
The default minimum size for flex items, providing a more reasonable default than 0 for other layouts.
max-content
自身想要的高度。
min-content
自身最小的高度。
fill-available
包含的块的高度减去水平方向上的margin、border和padding。一些浏览器用一个古老的名字实现了这个关键字,available
fit-content
根据CSS3和模型,这个和min-content是同义词。CSS3尺寸计算方式定义了一个更复杂的算法呢,但是还没有浏览器实现,甚至连实验模式都没有。

正式语法

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

例子

table { min-height: 75%; }

form { min-height: 0; }

规范

规范 状态 注释
CSS Intrinsic & Extrinsic Sizing Module Level 3
min-height
Working Draft Adds the max-content, min-content, fit-content, andfill-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.

浏览器兼容性

特性 Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
基本支持 1.0 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 未实现
特性 Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
基本支持 ? ? ? ? 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.

另见

文档标签和贡献者

 此页面的贡献者: zhyupe, Sebastianz, lazurey, ziyunfei
 最后编辑者: zhyupe,