我创建了一个简单的canvas元素入门
<canvas style="width:100%;height:100%;" id="canvas"></canvas>
当我试图让高度,但是在javascript canvas元素的高度:
var canvas = document.getElementById(config.elementId);
console.log(canvas.height); //150
console.log(canvas.width); //300
console.log(canvas.style.height); //100%
console.log(canvas.style.width); //100%
如果我检查的元素chrome的调试器,并且实际上将鼠标悬停在元素上,chrome报告的元素大小为
1627x925px
如何在地球上得到0在js中测量?
见接受这个问题的答案http://stackoverflow.com/questions/4938346/canvas-width-and-height-in-html5 – Musa