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>
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