HTML DOM 이미지 폭 속성
정의 및 사용
값 폭 속성 집합 또는 사진 폭 속성을 반환합니다.
폭이 속성은 이미지의 폭을 지정한다.
문법
imageObject.width=pixels
브라우저 지원
모든 주요 브라우저 폭 속성을 지원
예
예
그림의 높이와 너비를 변경합니다 :
<!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>
»시도
이미지 개체