min-height 属性设置元素的最小高度。
此属性可防止 height 属性的值变得小于为 min-height 指定的值。
min-height 属性覆盖了 max-height 和 height 属性。
该属性采用 CSS 长度(px、pt、em 等)或者百分比。
不接受负值。
初始值 | 0. |
---|---|
应用于 | 所有元素,除非未替换的内联元素,列组和表列。 |
继承 | 无效 |
可动画的 | 是的。高度是有动画的。 |
版本 | CSS2. |
DOM 语法 | object.Style.minheight =“100px”; |
CSS min-height 属性值说明
值 | 描述 |
---|---|
auto | 浏览器计算并为给定元素选择min-height。 |
length | 定义PX,Pt,cm等中的最小高度。默认值为0。 |
% | 设置包含元素%的最小高度。 |
initial | 使属性使用其默认值。 |
inherit | 从父母元素继承属性。 |
语法
min-height: length | initial | inherit;
min-height 属性的示例:
<!DOCTYPE html> <html> <head> <title>文档的标题</title> <style> div { min-height: 50px; background-color: #8ebf42; } </style> </head> <body> <h2>Min-height 属性示例</h2> <div>文本区域的最小高度定义为 50px。</div> </body> </html>
指定为“3cm”的 min-height 属性示例:
<!DOCTYPE html> <html> <head> <title>文档的标题</title> <style> p { background-color: #ccc; } p.example { min-height: 3cm; } </style> </head> <body> <h2>Min-height 属性示例</h2> <h3>Min-height: auto.</h3> <p></p> <h3>Min-height: 3cm.</h3> <p class="example">经历过风雨,才懂得阳光的温暖。</p> </body> </html>
日期:2020-06-02 22:14:39 来源:oir作者:oir