HTML DOM atributo Ancho de la imagen
Definición y Uso
Valor conjuntos de propiedades de anchura o devuelve las propiedades de anchura imagen.
atributo width especifica el ancho de la imagen.
gramática
imageObject.width=pixels
Soporte para el navegador
Todos los principales navegadores soportan atributo width
Ejemplos
Ejemplos
Cambiar la altura de la imagen y el ancho:
<!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>
Trate »
objeto de imagen