求大神看看我的为啥没效果

来源:2-1 JS速度动画

李李晨晨

2016-06-10 20:34

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<style type="text/css">

*{

margin:0;

padding:0;

}

#box{

position:relative;

left:-200px;

}

.one{

width:200px;

height:200px;

background-color:red;

float:left;

}

.two{

width:50px;

height:50px;

background-color:blue;

float:left;

margin-top:55px;

}

</style>

<script type="text/javascript">

window.onload=function(){

var odiv=document.getElementById("box");

odiv.onmouseover=function(){

starmove()

}

}

function starmove(){

setIntervav(function(){

var odiv=document.getElementById("box");

odiv.style.left=odiv.offsetLeft+10+"px";

},30);

}

</script>

</head>


<body>

<div id="box">

<div class="one"></div>

<div class="two">分享</div>

</div>

</body>

</html>


写回答 关注

1回答

  • lrylong
    2016-06-10 21:16:20

    setInterval写错了

JS动画效果

通过本课程JS动画的学习,从简单动画开始,逐步深入各种动画框架封装

113931 学习 · 1443 问题

查看课程

相似问题