目录

max-height

描述 (Description)

max-height属性用于设置元素高度的上限。

可能的值 (Possible Values)

  • length - 任何长度单位。 元素永远不会有超过此距离的高度值。

  • percentage - 将元素的高度限制为最多包含块高度的百分比。

  • none - 元素的高度没有限制。

适用于 (Applies to)

除了未替换的内联元素和表元素之外的所有HTML元素。

DOM语法 (DOM Syntax)

object.style.maxHeight = "50px"

例子 (Example)

这是一个例子 -

<html>
   <head>
   </head>
   <body>
      <p style = "width:400px; max-height:10px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
      </p>
      <img alt = "logo" src = "/css/images/logo.png" width = "95" height = "84" />
   </body>
</html>

这将产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018