CSS max-height 属性值说明

描述
none这是此属性的默认值。
length定义PX,PT,CM等中的最大高度。默认值为0。
%设置包含元素%的最大高度。
initial使属性使用其默认值。
inherit从父母元素继承属性。

语法

max-height: none | length | initial | inherit;

max-height 属性的示例:

<!DOCTYPE html>
<html>
  <head>
    <title>文档的标题</title>
    <style>
      p {
        max-height: 50px;
        overflow: auto;
        border: 1px solid #666;
        padding: 5px;
      }
    </style>
  </head>
  <body>
    <h2>Max-height 属性示例</h2>
    <p>我爱你时你正一贫如洗寒窗苦读,离开你时你正金榜题名洞房花烛。</p>
  </body>
</html>

定义为“cm”的 max-height 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>文档的标题</title>
    <style>
      .example1 {
        max-height: 2cm;
        overflow: auto;
        border: 1px solid #666;
        width: 300px;
      }
    </style>
  </head>
  <body>
    <h2>Max-height 属性示例</h2>
    <h3>Max-height: none;</h3>
    <p>我爱你时你正一贫如洗寒窗苦读,离开你时你正金榜题名洞房花烛。</p>
    <h3>Max-height: 2cm;</h3>
    <p class="example1">我爱你时你正一贫如洗寒窗苦读,离开你时你正金榜题名洞房花烛。</p>
  </body>
</html>
CSS max-height 属性

max-height 属性用于设置元素的最大高度。
此属性可防止 height 属性的值变得大于为 max-height 指定的值。

max-height 属性会覆盖 height 属性,而 min-height 属性会覆盖 max-height 属性。

初始值none
应用于所有元素,但未替换的内联元素,表列和列组。
继承无效
可动画的是的。高度是有动画的。
版本CSS2.
DOM 语法object.Style.maxheight =“50px”;
日期:2020-06-02 22:14:38 来源:oir作者:oir