在线文档教程
CSS

平均高度 | min-height

min-height

min-height CSS属性设置元素的最小高度。它防止使用的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 高度的值。

初始值0
适用于所有元素,但未被替换的内联元素,表列和列组
遗传没有
百分比百分比是根据生成的包含盒子的高度来计算的。如果包含块的高度没有明确指定(即,取决于内容高度),并且该元素没有被绝对定位,则将该百分比值视为0。
媒体视觉
计算值指定的百分比或绝对长度
动画类型一个长度,百分比或者calc();
规范的顺序形式语法定义的独特的非模糊顺序

语法

<length>最小高度,表示为a <length>。负值使声明无效。

关键字值

auto弹性项目的默认最小高度,为其他布局提供比0更合理的默认值。

形式语法

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

实例

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

规范

SpecificationStatusComment
CSS Intrinsic & Extrinsic Sizing Module Level 3The definition of 'min-height' in that specification.Working DraftAdds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
CSS Flexible Box Layout ModuleThe definition of 'min-height' in that specification.Candidate RecommendationAdds the auto keyword and uses it as the initial value.
CSS TransitionsThe definition of 'min-height' in that specification.Working DraftDefines min-height as animatable.
CSS Level 2 (Revision 1)The definition of 'min-height' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0(Yes)3.0 (1.9)7.0 34.01.0 2.0.2 (416) for positioned elements
applies to <table> 1No supportNo support(Yes)No support(Yes)No support
max-content, min-content, fit-content, and fill-availableNo supportNo supportNo supportNo supportNo support9
autoObsolete since Gecko 2221.0?16.0 (16.0)No support12.10No support
auto as initial valueObsolete since Gecko 2221.0?18.0 (18.0)No support12.10No support

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support?(Yes)???9