I tried to make responsive canvas in width (I don't want the height to be responsive, just the width) by width: 100%;
using css but canvas height got bigger that what I defined in html so as the canvas shapes and that made my canvas shapes got blurry, I searched the web for this and find no answer
Here is my code
**html**
<div class="container"><canvas id="myCanvas" height="420"></canvas></div>
**css**
.container { max-width: 960px; margin: 0 auto; }
#myCanvas {
margin: 30px 0;
background: white;
box-shadow: 4px 6px 30px #ddd;
width: 100%;
height: auto;
}
**javascript**
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.arc(100, 100, 80, 0, Math.PI * 2);
ctx.fill();
And here is the output from Firefox 62 that illustrate the problem you will notice that the canvas height is bigger that 420 and my circle is bigger that what I defined in the js FirefoxScreenShot
Better here is the output of the same code above in jsbin https://output.jsbin.com/coduke
after that Is there any way make html canvas responsive using css without having these issues