Style minHeight 屬性
Style 對(duì)象定義和用法
minHeight 屬性設(shè)置或返回元素的最小高度。
minHeight 屬性只在塊級(jí)元素或絕對(duì)/固定位置的元素發(fā)揮作用。
語(yǔ)法
設(shè)置 minHeight 屬性:
Object.style.minHeight="length|%|inherit"
返回 minHeight 屬性:
Object.style.minHeight
值 | 描述 |
---|---|
length | 使用 px、cm 等單位定義最小高度。默認(rèn)是 0。 |
% | 定義最小高度為父元素的百分比。 |
inherit | minHeight 屬性的值從父元素繼承。 |
瀏覽器支持
所有主要瀏覽器都支持 minHeight 屬性。
注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有規(guī)定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。
實(shí)例
實(shí)例
設(shè)置元素的最小高度:
<html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.minHeight="100px";
}
</script>
</head>
<body>
<p id="p1">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
<input type="button" onclick="displayResult()" value="Set min height">
</body>
</html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.minHeight="100px";
}
</script>
</head>
<body>
<p id="p1">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
<input type="button" onclick="displayResult()" value="Set min height">
</body>
</html>
嘗試一下 ?
Style 對(duì)象
更多建議: