Strange HTML5 Canvas drawImage behaviour

后端 未结 1 620
盖世英雄少女心
盖世英雄少女心 2020-12-14 01:42

I am writing some code that uses HTML5 canvas. Generally it works well, but now I found a very strange behaviour. The weird thing is that it is consistent on different brows

相关标签:
1条回答
  • 2020-12-14 02:24

    I found this "feature" as well to be a bit irksome. It seems as though you don't want to use CSS to set the width and height properties for the canvas element. Append the canvas element with attributes (rather than CSS) and the dimensions should correct themselves.

    var canvas = jQuery("<canvas/>", {
        'id' : this.viewId + "canvas"
    });
    
    $('#' + this.viewId).attr('height', this.height).attr('width', this.width);
    
    0 讨论(0)
提交回复
热议问题