这层级关系怎么搞,眼睛叠在头的上一层
来源:3-11 编程练习
慕仰2255090
2019-09-26 15:32:18
我这眼睛怎么不显示???
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas</title>
<style>
canvas{background-color:lightblue;}
</style>
</head>
<body>
<canvas id="canvas" width="800" height="800">
您的浏览器不支持canvas
</canvas>
<script>
//在此处写出代码
var cans=document.getElementById('canvas');
var conter=cans.getContext('2d');
conter.moveTo(300,50);
conter.lineTo(350,150);
conter.strokeStyle='yellow';
conter.stroke();
conter.beginPath();
conter.moveTo(500,50);
conter.lineTo(450,150);
conter.strokeStyle='yellow';
conter.stroke();
conter.fillStyle='#ffe1b5';
conter.fillRect(300,150,200,180);
conter.fillStyle='yellow';
conter.fillRect(270,180,30,50);
conter.fillRect(500,180,30,50);
conter.fillStyle='red';
conter.fillRect(350,270,100,30);
conter.fillStyle='pink';
conter.fillRect(330,330,140,240);
conter.fillStyle='green';
conter.fillRect(130,400,200,30);
conter.fillRect(470,400,200,30);
conter.fillRect(350,570,30,200);
conter.fillRect(420,570,30,200);
conter.beginPath();
conter.arc(350,220,20,0,2*Math.PI,true)
content.stroke();
conter.fillStyle='#000';
content.fill();
conter.beginPath();
conter.arc(450,220,20,0,2*Math.PI,true)
content.stroke();
conter.fillStyle='#000';
content.fill();
</script>
</body>
</html>
1回答
同学你好,这里不是层级的关系哦。没有显示是因为设置的变量为conter,但是下面这是个使用的都是content。
改为conter即可。例:
希望能帮助到你,欢迎采纳。
祝学习愉快!
相似问题