HTML DOM Image height 屬性
定義和用法
height 屬性可設置或者返回圖片的height 屬性值。
height 屬性指定了圖片的高度。
語法
imageObject.height=pixels
瀏覽器支持
所有主要瀏覽器都支持height 屬性
實例
實例
下面的例子可設置圖像的高度和寬度:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改圖像大小">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改圖像大小">
</body>
</html>
嘗試一下»
Image對象