CSS

高度 | @viewport.height

@viewport.height

heightCSS描述符是同时设置一个速记描述符min-heightmax-height视口。通过提供一个视口长度值将把所提供的值设置为最小高度和最大高度。

如果提供了两个视口值,则第一个值将设置最小高度,第二个值将设置最大高度。

Related at-rule@viewport
初始值as each of the properties of the shorthand: min-height: 0 max-height: none
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.
适用媒体visual, continuous
计算值as 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
正规顺序order of appearance in the formal grammar of the values

  • min-height0

  • max-heightnone

Percentages as each of the properties of the shorthand:

  • min-height:百分比是根据生成的包含块的框%27s的高度计算的。如果未显式指定包含块的高度%28i。e.它取决于内容高度%29,并且该元素不是绝对定位的,百分比值被视为0

  • max-height:百分比是根据生成的包含块的框%27s的高度计算的。如果未显式指定包含块的高度%28i。e.它取决于内容高度%29,并且该元素不是绝对定位的,百分比值被视为none

Media visual, continuous [Computed value](../computed_value) as each of the properties of the shorthand:

  • min-height:指定的百分比或绝对长度

  • max-height:指定的百分比或绝对长度或none

Canonical order order 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; }

规范

SpecificationStatusComment
CSS Device AdaptationThe definition of '"height" descriptor' in that specification.Working DraftInitial definition

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support29 (behind a flag)No support10 -ms11.10 Removed in 15 Reintroduced behind a flag in 16No support

FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support4.429No support10-ms11.10 Removed in 15 Reintroduced behind a flag in 16No support