<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{margin:0;padding:0;}
#fuck{
top=0;
width:200px;
height:200px;
background:#00FFFF;
position:relative;
left:-200px;
}
#share{
width: 20px;
height: 50px;
background: blue;
position: absolute;
left: 200px;
top:75px;
}
</style>
</head>
<body>
<script>
window.onload=function(){
var fuck=document.getElementById("fuck");
fuck.onmouseover=function(){
outmove(0);
}
fuck.onmouseout=function(){
outmove(-200);
}
}
var timer= null;
var speed=0;
function outmove(iTarget){
var fuck=document.getElementById("fuck");
clearInterval(timer);
timer=setInterval(function(){
if(fuck.offsetLeft<iTarget){
Math.ceil(speed=(iTarget-fuck.offsetLeft)/30);
}else{
Math.floor(speed=(iTarget-fuck.offsetLeft)/30);
}
if(fuck.offsetLeft==iTarget){
clearInterval(timer);
}else{
fuck.style.left=fuck.offsetLeft+speed+"px";
}
},30);
}
</script>
<div id="fuck">
<span id="share">分享</span>
</div>
</body>
</html>
为什么这样,达不到老师那样的效果?