MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

height

概要

高度 的 CSS 描述符是用於設定兩者的簡易描述符 min-heightmax-height 的可視區域(viewport)。提供一個可視區域的長度值,將設定兩者的最小高度與最大高度的值。

如果提供了兩個可視區域(viewport),第一個值將設定為最小高度,而第二個值將設定為最大高度。

Related at-rule@viewport
預設值as each of the properties of the shorthand:
Percentagesas each of the properties of the shorthand:
  • min-height: 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.
  • max-height: 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 none.
Mediavisual, continuous
Computed valueas each of the properties of the shorthand:
  • min-height: the percentage as specified or the absolute length
  • max-height: the percentage as specified or the absolute length or none
Canonical orderorder of appearance in the formal grammar of the values

語法

/* One value */
height: auto;
height: 320px;
height: 15em;

/* Two values */
height: 320px 200px;

auto
使用 CSS 描述符來進行值的計算。
<length>
非負絕對值或相對長度。
<percentage>
初始可視區域的相對寬度或相對高度百分比的縮放係數為 1.0,且必須是非負數。

正式語法

<viewport-length>{1,2}

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

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

舉例

@viewport {
  height: 500px;
}

格式

Specification Status Comment
CSS Device Adaptation
The definition of '"height" descriptor' in that specification.
Working Draft Initial definition

瀏覽器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 29 (behind a flag) No support 10 -ms 11.10
Removed in 15
Reintroduced behind a flag in 16
No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 4.4 29 No support 10-ms 11.10
Removed in 15
Reintroduced behind a flag in 16
No support

文件標籤與貢獻者

 此頁面的貢獻者: yvonne6344
 最近更新: yvonne6344,