DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> HTML基礎知識 >> HTML5詳解 >> html5教程畫矩形代碼分享
html5教程畫矩形代碼分享
編輯:HTML5詳解     
復制代碼代碼如下:
<!DOCTYPE Html><head> 
<meta charset=utf-8> 
<title>Html5畫矩形</title>
<script src="<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.JS"></script">http://ajax.googleapis.com/AJax/libs/jquery/1.7.1/jquery.min.JS"></script</a>>
</head> 
<script>
$(document).ready(function(){
var c=document.getElementById("drawbox");
var draw=c.getContext("2d"); //獲取2d內容的引用,調用繪圖API
draw.fillStyle="#ff0000"; //方式一指定填充顏色
draw.fillRect(0,0,300,100); //坐標和長寬
draw.fillStyle="rgba(0,0,255,0.5)"; //方式二rgb+透明度
draw.fillRect(400,0,100,100); //坐標和長寬
})
</script>
</body>
<canvas id="drawbox" width="500" height="500"></canvas>
</body> 
</Html>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved