How to resize html canvas element?

后端 未结 7 1849
慢半拍i
慢半拍i 2020-11-29 01:34

I have a canvas element defined statically in the html with a width and height. If I attempt to use JavaScript to resize it dynamically (setting a new width and height - eit

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 02:31

    Note that if your canvas is statically declared you should use the width and height attributes, not the style, eg. this will work:

    
    
    

    But this will not work:

    
    
    

提交回复
热议问题