min-height

CSS min-height Property

The min-height property sets an element’s minimum height. This property prevents the height property’s value from becoming smaller than the value specified for min-height.

The min-height property overrides the max-height and height properties.

The property takes a CSS length (px, pt, em, etc.) or a percentage.

Negative values are not accepted.

类目类目
Initial Value0
Applies toAll elements, except non-replaced inline elements, column groups and table columns.
InheritedNo.
AnimatableYes. Height is animatable.
VersionCSS2
DOM Syntaxobject.style.minHeight = “100px”;

Syntax

Syntax

min-height: length | initial | inherit;

Example of the min-height property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        min-height: 50px;
        background-color: #8ebf42;
      }
    </style>
  </head>
  <body>
    <h2>Min-height property example</h2>
    <div>The text area's minimum height is defined as 50px.</div>
  </body>
</html>

Result

Example of the min-height property specified as “3cm”:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p {
        background-color: #ccc;
      }
      p.example {
        min-height: 3cm;
      }
    </style>
  </head>
  <body>
    <h2>Min-height property example</h2>
    <h3>Min-height: auto.</h3>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
    <h3>Min-height: 3cm.</h3>
    <p class="example">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Values

Values

ValueDescriptionPlay it
autoThe browser calculates and selects a min-height for the given element.Play it »
lengthDefines minimum height in px, pt, cm, etc. Default value is 0.Play it »
%Sets the minimum height in % of containing element.
initialMakes the property use its default value.Play it »
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部