Make Html5 Canvas and Its contained image responsive across browsers

后端 未结 2 1445
抹茶落季
抹茶落季 2020-12-17 05:27

I have a canvas object that I want to put an image in for a web application. I can get the image loaded, but I\'ve run into 2 problems: The image won\'t stretch to the canva

2条回答
  •  失恋的感觉
    2020-12-17 05:58

    
    

    Both CSS and height and width attributes can be used and do not need to agree in size. The CSS style will determine the displayed size, you asked for a canvas that can stretch. The width and height control the number of pixels the canvas uses for drawing.

    for example this will be scaled 10 to 1, and with anti-aliasing scrolling an drawing in this canvas would be as smooth as silk.

    
    

    If CSS is not used, their defaults will be the width and height attributes of the canvas element.

提交回复
热议问题