How to avoid HTML Canvas auto-stretching

前端 未结 5 1561
盖世英雄少女心
盖世英雄少女心 2021-01-01 11:12

I have the following piece of HTML:



&l         


        
5条回答
  •  萌比男神i
    2021-01-01 12:02

    Ok, a little bit simplier (and lighter) than JQuery is .. JAVASCRIP ITSELF of course !

    If you need to change dynamicaly your canvas dimensions, just use:

    document.getElementById('yourcanvasid').setAttribute('width', aWidth);
    document.getElementById('yourcanvasid').setAttribute('height', aHeight);
    

提交回复
热议问题