Why does the canvas appear scaled when height and width are specified in css instead of DOM?
Html:
<canvas></canvas>
Css:
canvas{ width:100px; height:100px; }
You can set the width and height on the canvas using CSS - but
canvas width, the height attribute defines the actual pixel that will be used to draw on the canvas. It is used for the canvas coordinate system.
CSS width / height, on the other hand, is related to the window model.
300px 150px. / CSS canvas, 300px/150px. 300px/150px, / CSS 100px/100px. ? ? .
HTML - https://html.spec.whatwg.org/multipage/scripting.html#attr-canvas-width
, .
:
css html, ( , ).
, , , , , . , , .
, , . ,
<canvas width="300" height="300"></canvas>
canvas height width. javascript-:
canvas
height
width
var canvas = document.getElementsByTagName('canvas')[0]; canvas.width = 100; canvas.height = 100;
, , , css, "" , . "", , .
, , . , CSS?
-
border: 1px solid;
css . fiddle