相关疑难解决方法(0)

使用CSS时画布被拉伸,但是"宽度"/"高度"属性正常

我有2个画布,一个使用HTML属性widthheight调整大小,另一个使用CSS:

<canvas id="compteur1" width="300" height="300" onmousedown="compteurClick(this.id);"></canvas>
<canvas id="compteur2" style="width: 300px; height: 300px;" onmousedown="compteurClick(this.id);"></canvas>
Run Code Online (Sandbox Code Playgroud)

Compteur1显示它应该,但不是compteur2.内容使用300x300画布上的JavaScript绘制.

为什么会有显示差异?

替代文字

css height html5 canvas width

181
推荐指数
5
解决办法
7万
查看次数

标签 统计

canvas ×1

css ×1

height ×1

html5 ×1

width ×1