我对如何指定html2canvas生成的图像大小感到困惑.例如,我希望能够将DIV保持为400px x 400px,但渲染图像为1200px x 1200px.我看过
the documentation,但我误解了如何应用它.我尝试添加a.width:1200; a.height:1200;没有运气.
我究竟做错了什么?
我的保存功能,来自我的JS:
$('#save').click(function() {
html2canvas($('#imagesave'), {
onrendered: function(canvas) {
var a = document.createElement('a');
a.href = canvas.toDataURL("image/png");
a.download = 'myfile.png';
a.click();
}
});
});
HTML
...
Save
CSS
#imagesave {
background-color: white;
height: 400px;
width: 400px;
}