我试图在我的桌子的一个单元格中画一个酒吧。
一切正常,但每次我更改浏览器窗口大小时,我的元素都会丢失。当我手动更改单元格大小时也会发生同样的情况。
有人可以帮忙吗?
我的画布是这样构建的
在 HTML 中:
<canvas id='0' width='260' height='10'> </canvas>
在 Javascript 中:
var canvas = document.getElementById(0);
if (canvas && canvas.getContext) {
ctx = canvas.getContext('2d');
if (ctx) {
ctx.strokeStyle = 'red';
ctx.stroke();
ctx.fillStyle = '#8b0000';
ctx.fill();
ctx.font = "Bold 11px Arial";
ctx.fillText("Test", canvas.width - 248, canvas.height);
}
}