1<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;"></canvas>
点击运行
<canvas></canvas>创建一个画布
本身没有绘图功能,需要搭配JavaScript来绘图
1234var c = document.getElementById("myCanvas");//首先,找到<canvas>元素var ctx = c.getContext("2d");//创建context对象ctx.fillStyle = "#FF0000";//颜色ctx.fillRect(0, 0, 150, 75); //大小 fillRect(x,y,width,height)
点击运行
阅读全文