<html>
<head>
<title>无标题文档</title>
<style>
#div1{
width:150px;
height:300px;
background:lime;
position:absolute;
left:-150px;
top:150px;
}
#div1 span{
width:20px;
height:60px;
position:absolute;
background:pink;
right:-20px;
top:110px;
}
</style>
<script>
window.οnlοad=function(){
var oDiv=document.getElementById('div1');
oDiv.οnmοuseοver=function(){
move(0);
}
oDiv.οnmοuseοut=function(){
move(-150);
}
var times;
function move(iTarget){
clearInterval(times);
times=setInterval(function(){
var speed;
if(oDiv.offsetLeft < iTarget){
speed=10;
}
else{
speed=-10;
}
if(oDiv.offsetLeft == iTarget){
clearInterval(times);
}
else{
oDiv.style.left=oDiv.offsetLeft+speed+'px';
}
},30);
}
}
</script>
</head>
<body>
<div id='div1'>
<span>分享到</span>
<a href="http://www.baidu.com">百度</a>
</div>
</body>
</html>
效果图: