在javascript中定义.style.height不能使用canvas图像

时间:2016-10-07 10:59:14

标签: javascript

我有以下代码,由于某种原因,我无法弄清楚,它不起作用。我试过了两个:     image.style.height = '10px';image.height = '10px';

var canvas = document.getElementById('canvas');
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
var image = new Image();
image.src = "http://pngimg.com/upload/horse_PNG2523.png";
image.style.height = '10px';
image.style.width = '20px';

0 个答案:

没有答案