html - 无法在特定尺寸的 Canvas 上绘制

标签 html google-chrome canvas

出于某种原因,如果以下代码中的第二个 Canvas 的高度超过 526 像素,Chrome 中将不会向其绘制任何内容。只要高度 < 527,它就可以正常工作,并且始终在 Firefox 中工作。有人知道我做错了什么吗?我是 HTML 的新手,如果我错过了什么,我深表歉意。

<!doctype html>
<html>
  <head>
 <script type="text/javascript">

function init()
{
    var canv = document.getElementById("myCanvas");
    var ctx = canv.getContext("2d");
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, canv.width, canv.height);
}

</script>
<style type="text/css">
canvas {border: 1px solid black; }
</style>
</head>
<body onload="init()">
<canvas id="mainFrame" width="700" height="700"></canvas>
<canvas id="myCanvas" width="125" height="527"></canvas> <!-- cannot exceed
526 ... WHY? -->
</body>
</html>

最佳答案

我在 win7 x64 上的 chrome v.24.0.1312 上试过这个,它按原样工作,请尝试更新到最新版本的浏览器。

关于html - 无法在特定尺寸的 Canvas 上绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14095991/

相关文章:

css - Google Chrome > 文本框 > 激活时出现黄色边框..?

javascript - 在 JavaScript 中使用鼠标事件在 Canvas 上绘制直线

google-chrome - 获取 DNS_PROBE_FINISHED_BAD_CONFIG 错误

javascript - 获取调整后的 html 图像元素的原始尺寸

javascript - 幻灯片放映中的 Zindex 图像

html - 网站在 IE9 中看起来正常,但在 Firefox、IE8 和 IE7 中不正常

css - 在网页上使用 Avant Garde BK BT 字体?

javascript - GOJS 将 Canvas 图导出为图像

javascript - 我需要从线段绘制三 Angular 形 - 如何找到中心点?

html - 页脚向上推以调整内容 div 中的图像大小