codecamp

HTML DOM Style minHeight 属性

Style minHeight 属性

Style 对象参考手册 Style 对象

定义和用法

minHeight 属性设置或返回元素的最小高度。

minHeight 属性只在块级元素或绝对/固定位置的元素发挥作用。

语法

设置 minHeight 属性:

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

返回 minHeight 属性:

Object.style.minHeight

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


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 minHeight 属性。

注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有规定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。


实例

实例

设置元素的最小高度:

<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 对象参考手册 Style 对象
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

HTML DOM对象

HTML DOM 引用对象

HTML DOM Password 对象

HTML DOM Link 对象

HTML DOM Select 对象

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }