老师,我这个咋不颤抖。。。

来源:2-3 存储实现打怪小案例

慕粉8021849

2020-02-01 18:11:27

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<style type="text/css">

*{

padding: 0;

margin: 0;

}

.doudou{

position: absolute;

top:40%;

left: 30%;

height:200px;

}

.blood{

position: absolute;

height:30px;

width:260px;

border: 1px black solid;

left: 30%;

top:5%;

}

.xue{

height:100%;

width:260px;

background-color: red;

}


</style>

</head>

<body>

<img src="豆豆.jpg" class="doudou">

<div class="blood">

<div class="xue"></div>

</div>

<script type="text/javascript">

var num=0,timer=null;

onclicK=function(){

clearInterval(timer);

timer=setInterval(function(){

num++;

if(num==5){

clearInterval(timer);

return;

};

document.body.style.left=Math.random()*-20+10+"px";

document.body.style.top=Math.random()*-20+10+"px";

})

}

</script>

</body>

</html>


写回答

1回答

樱桃小胖子

2020-02-02

同学你好,代码存在以下问题

http://img.mukewang.com/climg/5e369aa1097313fa05030656.jpg

http://img.mukewang.com/climg/5e369ab60959694506550331.jpg

如果我的回答帮助了你,望采纳,祝学习愉快!

0

0 学习 · 6815 问题

查看课程