老师,我这个咋不颤抖。。。
来源: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回答
同学你好,代码存在以下问题
如果我的回答帮助了你,望采纳,祝学习愉快!
相似问题