Home › Forums › CSS › canvas width in % not works get converted to px › Reply To: canvas width in % not works get converted to px
November 27, 2014 at 9:41 am
#189371
Participant
AFAIK the height and width defined as attributes of a canvas element, just define the the original size of the canvas, just like every image already has its own width and height (which is used, when width:auto; and height: auto; are set by CSS).
So it should be possible to generate a canvas with a certain size (defined by width and height attributes) and resize it afterwards by using css width and css height:
<canvas id=”canvas” width=”1000″ height=”500″></canvas>
#canvas {
width: 100%;
}
The quality might suffer through this, as the canvas is resized by css, but basically it should work.