max-height CSS descriptor specifies the maximum height of the viewport of a document defined via the @viewport at-rule.

The height will initially be set as close as possible to the initial viewport height considering the maximum height constraint.

句法

/* Keyword value */
max-height: auto;
/* <length> values */
max-height: 400px;
max-height: 50em;
max-height: 20cm;
/* <percentage> value */
max-height: 75%;
					

auto

The used value is calculated from the other CSS descriptors' values.

<length>

A non-negative absolute or relative length.

<percentage>

A percentage value relative to the height of the initial viewport at zoom factor 1.0 for vertical lengths. Must be non-negative.

形式定义

相关 at-rule @viewport
初始值 auto
百分比 refer to the height of the initial viewport
计算值 if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto

形式句法

<viewport-length>

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

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

范例

Setting viewport max height in pixels

@viewport {
  max-height: 600px;
}
					

规范

规范 状态 注释
CSS Device Adaptation
The definition of '"max-height" descriptor' 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
max-height descriptor Chrome 不支持 29 — 84 Edge 完整支持 12 Prefixed
完整支持 12 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Firefox 不支持 No IE 完整支持 10 Prefixed
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 16
完整支持 16
不支持 11.1 — 15
Safari 不支持 No WebView Android 不支持 4.4 — 37 Chrome Android 不支持 29 — 84 Firefox Android 不支持 No Opera Android 完整支持 16
完整支持 16
不支持 11.1 — 14
Safari iOS 不支持 No Samsung Internet Android 完整支持 2.0

图例

完整支持

完整支持

不支持

不支持

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

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

另请参阅

元数据

  • 最后修改: