<canvas id="myCanvas" width=200 height=100 style="border:solid 1px #000"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "#ff0000";
ctx.fillRect(0,0,50,50);
</script>
属性里width 和 height 设置画板和画纸的宽高
css里的宽高只设置画板的宽高,画纸的宽高还是默认的300*150,所以会导致压缩