Latest web development tutorials

HTML DOM Style minHeight property

Style Object Reference Style Objects

Definition and Usage

minHeight property sets or returns the element's minimum height.

minHeight properties play a role only in the block-level element or elements of absolute / fixed position.

grammar

Setting minHeight properties:

Object.style.minHeight="length|%|inherit"

Back minHeight properties:

Object.style.minHeight

描述
length 使用 px、cm 等单位定义最小高度。默认是 0。
% 定义最小高度为父元素的百分比。
inherit minHeight 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support minHeight property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Set minimum height element:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.minHeight="100px";
}
</script>
</head>
<body>

<p style="background:red;" id="p1">这是一些文本。这是一些文本。这是一些文本。这是一些文本。这是一些文本。这是一些文本。这是一些文本。</p>
<input type="button" onclick="displayResult()" value="设置元素最小高度">

</body>
</html>

try it"


Style Object Reference Style Objects