<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>时钟</title>
<style type="text/css">
div{
text-align: center;
margin-top: 250px;
}
#c1ock{
width: 200px;
height: 200px;
border: 1px solid #cccccc;}
</style>
</head>
<body>
<div>
<canvas id="c1ock" ></canvas></div>
<script type="text/javascript">
var a1=document.getElementById("clock");
var ctx=a1.getContext("2d");
var kuan=ctx.canvas.width;
var gao=ctx.canvas.height;
var r= width/2;
function sex() {
ctx.translate(r,r);
ctx.beginPath();
ctx.lineWidth = 10;
ctx.arc(0,0,r-5,0,2*Math.PI,false);
ctx.stroke();
}
sex();
</script>
</body>
</html>
id="clock" 不是 1(一)
是kuan/2(width没定义)
canvas样式要写在行间
clock 单词拼写有问题 ,有的你写成了 c1ock;
<canvas id="clock" width="200" height="200"></canvas> 画布的大小要放在标签里,不能写在样式表里;
var r= width/2; 改成 var r= kuan/2;