HTML DOM height 屬性
定義和用法
height 屬性設置元素的高度。
語法:
Object.style.height=auto|length|%
可能的值
值 | 描述 |
---|---|
auto | 默認。瀏覽器會計算出實際的高度。 |
length | 使用 px、cm 等單位定義高度。 |
% | 基于其包含塊的百分比高度。 |
實例
本例設置按鈕的高度:
<html>
<head>
<script type="text/javascript">
function setHeight()
{
document.getElementById("b1").style.height="50px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="setHeight()"
value="Change height of button to 50 px" />
</body>
</html>