源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>编程字典</title> </head> <body> <canvas id="myCanvas">你的浏览器不支持HTML5 canvas标签.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0, 0, 80, 100); </script> <p><strong>注意:</strong> IE8和早期版本不支持 canvas 标签</p> </body> </html>
运行结果