<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body {
            margin:0px;
            padding:0px;
        }
        #aa{
            border:1px solid blanchedalmond;
            background-color:blue;
        }
    </style>
    <script>
        window.onload =function(){
            var canvas=document.getElementById("aa");
            var context =canvas.getContext ("2d");
            context.beginPath();
            context.moveTo (200,canvas.height/2)
            context.lineTo (canvas.width-200,canvas.height /2);
            context.lineWidth =20;
            context.strokeStyle ="#ff00000";
            context.lineCap ="round";
            context.stroke ();
            context.beginPath();
            context.moveTo (200,canvas.height/2+50)
            context.lineTo (canvas.width-200,canvas.height /2);
            context.lineWidth =20;
            context.strokeStyle ="#ff00000";
            context.lineCap ="square";
            context.stroke ();
        };
    </script>
</head>
<body>
<canvas id="aa" width="578" height="200">
</canvas>
</body>
</html>
与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之三
原文:http://www.cnblogs.com/mikou2017/p/6883219.html