我尝试在整页 Canvas 上放置一个 div。在 Chrome 中效果很好,但在 firefox 和 ie9 中它会“卡普特”。
这是该代码的链接(在 Firefox chrome 和 ie9 中尝试过),似乎只有 chrome 可以工作;
最佳答案
在 IE9 文档中没有属性 document.width/document.height
,因此您将 Canvas 宽度/高度设置为 0。
尝试使用
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
或
canvas.width = $(document).width();
canvas.height = $(document).height();
关于javascript - Html5 div 在 Canvas 上跨浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12871758/