1<! DOCTYPE html>234<title>insert you title</title>5<meta name= ' description ' content= ' This is my page ' >6<meta name= ' keywords ' content= ' keyword1,keyword2,keyword3 ' >7<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<link rel= ' stylesheet ' type= ' text/css ' href= './css/index.css '/>9<script type= ' text/javascript ' src= './js/jquery-1.12.1.min.js ' ></script>Ten<style type= ' text/css ' > One Html,body { Amargin:0; padding:0; - } - the HTML { -height:100%; - } - + Body { -Background: #000; + } A at #can { -Display:block; border-radius:2px, margin:25px Auto; background: #FFF; - } -</style> -<script type= ' Text/javascript ' > -$(function(){ in varOcan = $ (' #can '). Get (0). GetContext (' 2d ' ); - /*Create a linear gradient mode*/ to //var clg = ocan.createlineargradient (0,0,500,450); /* Parameter: Start point end point coordinates */ + //clg.addcolorstop (. 3, ' #F00 '); /* Parameter: Starting point coordinates 0-1 can be multiple, color value */ - //clg.addcolorstop (. 5, ' #FF0 '); /* Parameter: Starting point coordinates 0-1 can be multiple, color value */ the //Clg.addcolorstop (. 7, ' #F0F '); /* Parameter: Starting point coordinates 0-1 can be multiple, color value */ * //clg.addcolorstop (1, ' #0FF '); /* Parameter: Starting point coordinates 0-1 can be multiple, color value */ $ //Ocan.fillstyle = CLG; /* Fill method is required * /Panax Notoginseng //Ocan.fillrect (0,0,500,450); - the /*Create radial gradients in this same way, not in demo ...*/ + varCLG = Ocan.createradialgradient (270,3,70,500,450,5);/*parameters: Starting point end point coordinate radius value*/ AClg.addcolorstop (. 3, ' #F00 ');/*parameters: Starting point coordinate 0-1 can be multiple, color value*/ theClg.addcolorstop (. 5, ' #FF0 ');/*parameters: Starting point coordinate 0-1 can be multiple, color value*/ +Clg.addcolorstop (. 7, ' #F0F ');/*parameters: Starting point coordinate 0-1 can be multiple, color value*/ -Clg.addcolorstop (1, ' #0FF ');/*parameters: Starting point coordinate 0-1 can be multiple, color value*/ $Ocan.fillstyle = CLG;/*Fill method is required*/ $Ocan.fillrect (0,0,500,450); - } ); -</script> the -<body>Wuyi<canvas id= ' can ' width= ' height= ' > Your browser version is too low, please upgrade your browser to get a better experience ...</canvas> the</body> -
[HTML createlineargradient createradialgradient draw background gradient] Canvas draw gradient createlineargradient createradialgradient To draw a background gradient style property instance