If I using HTML/CSS to set the height and width for Canvas element,
another problem raised: as the following code, I want to draw a
rectangle with height & width = 20px, but the graphics is much more
bigger than what I want to draw. anyone knows what be happened?
<html>
<head>
<title>A canvas example</title>
<script type="text/javascript">
function draw() {
var ctx = document.getElementById('cv').getContext('2d');
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, 20, 20);
}
</script>
</head>
<body onload="draw();">
<div style="border:1px solid #CCCCCC;width:32768px;height:
460px;overflow:auto">
<canvas id="cv" style="width:32768px;height:460px"></canvas>
</div>
</body>
</html>