搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
HTML5基础教程
HTML5 图形
源代码
清空
点击运行
<canvas id="ex1" width="500" height="100" style="border: 1px solid #cccccc;">HTML5 Canvas not supported</canvas> <script> var canvas = document.getElementById("ex1"); var context = canvas.getContext("2d"); context.fillStyle ="#66ff66"; context.strokeStyle="#990000"; context.lineWidth = 5; context.fillRect (5, 5, 50, 50); context.strokeRect(5, 5, 50, 50); context.save(); context.fillStyle = "#6666ff"; context.fillRect (65, 5, 50, 50); context.strokeRect(65, 5, 50, 50); context.save(); context.strokeStyle = "#000099"; context.fillRect (125, 5, 50, 50); context.strokeRect(125, 5, 50, 50); context.restore(); context.fillRect (185, 5, 50, 50); context.strokeRect(185, 5, 50, 50); context.restore(); context.fillRect (245, 5, 50, 50); context.strokeRect(245, 5, 50, 50); </script>
运行结果