日期:2014-05-16  浏览次数:20387 次

HTML5 canvas相关
给canvas用css设置高和宽后会出问题((100,100)的位置不是中点):
<canvas id="canvas" style="width:400px;height:400px;"></canvas>

<script type="text/javascript">
var canvas=document.getElementById('canvas');
var context=canvas.getContext('2d');

context.moveTo(0,0);
context.lineTo(100,100);

context.strokeStyle='#ff0';


context.stroke();
</script>
而不设置高和宽,或者用html的方式设置宽和高就正常了:
<canvas id="canvas" width="400px" height="400px"></canvas>

------解决方案--------------------
楼主 参考下 

http://www.189works.com/article-44786-1.html

http://topic.csdn.net/u/20090104/10/520825ed-97f9-42d1-8e26-9bcd2b134a3a.html