【发布时间】:2019-05-06 22:20:58
【问题描述】:
我有一个网页,我在其中使用var img = document.createElement("img"); 创建了一个图像标签,但在下一行我也使用了元素高度和宽度,但它不能正常工作:
var base64_string = response.response.data[i].data;
var img = document.createElement("img");
// added `width` , `height` properties to `img` attributes
img.css({
'width' : '100px',
'height' : '100px'
});
img.src = "data:image/jpeg;base64," + base64_string;
var preview = document.getElementById("images");
preview.appendChild(img);
为什么此代码中的高度和宽度不起作用?请给我一些建议。
【问题讨论】: