canvas是html5中新增的標(biāo)簽杠园,用于配合js繪制圖形
創(chuàng)建一個(gè)畫布
<style type="text/css">
#box{
position: absolute;
left: 0;
right: 0;
margin:50px auto;
background-color: #eee;
}
</style>
<canvas id="box" width="800" height="400">
canvas 是一個(gè)二維網(wǎng)格懈凹。左上角坐標(biāo)為 (0,0)
利用js畫一個(gè)矩形
var c=document.getElementById("box");
var ctx=c.getContext("2d");
ctx.fillStyle="#00bcda";
ctx.fillRect(0,0,150,75);