2 位贡献者:


height 指定元素内容区高度。 内容区 content area 在元素padding, border, and margin 的里面。

min-height  与  max-height 覆盖 height.

  • 初始值 auto
  • 适用元素 all elements but non-replaced inline elements, table columns, and column groups
  • 可继承 no
  • Percentages 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 value computes to auto. A percentage height on the root element is relative to the initial containing block.
  • 适用媒体 visual
  • 计算值 a percentage or auto or the absolute length
  • 可动画 yes, as a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
  • Canonical order the unique non-ambiguous order defined by the formal grammar


Formal syntax: auto | <length> | <percentage>
height: auto     /* auto keyword */

height: 120px    /* <length> values */
height: 10em

height: 75%      /* <percentage> values */

height: inherit


可用单位查看 <length>
<percentage> 相对于元素的块容器高度。如果块容器的高度没有显式指定,计算值为 auto。 用在root 元素 (e.g. <html>) 上是相对于初始块容器(即神器的尺寸)。



table { height: 100%; }

img { height: 200px; }

form { height: auto; }

/* make sure percentage height of body's children works as expected */
html, body { margin: 0; height: 100%; }


Specification Status Comment
CSS Basic Box Model Working Draft Added the max-content, min-content, available, fit-content, border-box, content-box keywords.
CSS Transitions Working Draft Lists height as animatable.
CSS Level 2 (Revision 1) Recommendation Adds support for the <length> values and precises on which element it applies to.
CSS Level 1 Recommendation Initial specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 4.0 7.0 1.0
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 1.0 (1) 6.0 6.0 1.0

See also


向此页面作出贡献: teoli, yan
最后编辑者: teoli,