开发者

How can i change the size of a HTML canvas

how can i change the size of an html canvas through a function? i tried Width=123;" and canvas.style.Width=123 canvas.width=123 neither of them worked heres the HTML code for the canvas <CANVAS id="canvas" width="460px" height="800px">开发者_如何学Python;</CANVAS> and in the css canvasarea { width: 460px; height: 800px;


the <canvas> element supports the width attribute.

example: <canvas width="123"></canvas>

to change the width with javascript do something like:

<canvas id="myCanvas"></canvas>

<script type="javascript">

function changeCanvasWidth() {
    myCanvas = document.getElementById("myCanvas");
    myCanvas.style.width="123px";
}
</script>

reference: http://www.w3schools.com/html5/tag_canvas.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜