How to avoid HTML Canvas auto-stretching

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

I have the following piece of HTML:



&l         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 11:55

    It's worth noting that the Width and Height attributes of canvas are not like the old school width and height attributes. They are not a substitute for CSS. They specify how many pixels the pixel buffer in the canvas itself should have, and if you don't apply a size to it with css, css will imply it's size from that shape of that pixel buffer. Setting the element's size in css does not set the size of the pixel buffer - it resizes it. From a CSS perspective, a is entirely the same thing as an .

提交回复
热议问题