HTML DOM atribut Gambar lebar
Definisi dan Penggunaan
Nilai set properti lebar atau mengembalikan sifat lebar gambar.
Atribut width menentukan lebar gambar.
tatabahasa
imageObject.width=pixels
Dukungan Browser
Semua browser utama mendukung atribut width
contoh
contoh
Mengubah tinggi gambar dan lebar:
<!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>
Coba »
gambar Object