先谢谢大神啦!!
<style type="text/css">
*{margin:0;padding:0;}
#d1{
width:200px;
height:100px;
background-color:#0f3;
position:relative;
left:-200px;
}
#d1 span{
width:25px;
height:50px;
background:yellow;
position:absolute;
right:-23px;
top:50px;
display:block;
}
</style>
<script >
window.onload=function(){
var oid=document.getElementyById('d1');
oid.onmouseover=function(){
startmove(0);
}
oid.onmouseout=function(){
startmove(-200);
}
}
var timer=null;
function.startmove(offsetleft){
clearInterval(timer);
timer=setInterval(function(){
var speed=0;
var oid=document.getElementById('d1');
if(oid.offsetLeft>offsetleft){
speed=10;
}
else{
clearInterval(timer);
}oid.style.left=oid.offsetLeft+speed+'px';
},30);
}
</script>
<div id="d1"><span>分享</span></div>
引晴上初
相关分类