Resize HTML5 canvas element

前端 未结 3 1590
温柔的废话
温柔的废话 2021-01-07 01:48

How can I achieve, so that the HTML5 canvas element ist resizeable?

I would like to implement this element so that you can scale it in any size. The event of the sca

3条回答
  •  轮回少年
    2021-01-07 01:59

    I think you need to bind the onresize event to your body of document.

    Then inside the the event you need to resize the canvas using window.innerWidth and window.innerHeight.

    Have a look @ http://kile.stravaganza.org/lab/js/canvas_resize/ (view source)

提交回复
热议问题