首页 > Web开发 > 详细

js 分享 运动框架

时间:2017-05-09 22:11:27      阅读:273      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1{
    width:100px;
    height:200px;
    background:red;
    position:absolute;
    left:-100px
    
}
#span1{
    width:20px;
    height:60px;
    background:blue;
    position:absolute;
    line-height:20px;
    top:70px;
    right:-20px;
}
</style>
<script>
window.onload=function(){
    var odiv=document.getElementById(div1);
    
    odiv.onmouseover=function(){
        onStart(0);
        }
        odiv.onmouseout=function(){
        onStart(-100);
        }
        
    }
    var timer=null;
function onStart(oTag){
        var odiv=document.getElementById(div1);
    clearInterval(timer);
    var speed=null;
    if(speed>oTag){
        speed=-10;
        }else{
            speed=10;
            }
    timer=setInterval(function (){
    
        if(odiv.offsetLeft==oTag){
            clearInterval(timer);
            }else{
                odiv.style.left=odiv.offsetLeft+speed+px;
                }
        },30)
    }
    
    
</script>
</head>

<body>
<div id="div1">
<span id="span1">分享到</span>
</div>
</body>
</html>

关于速度的小解释

分享框
left30 tag300 正
left600 tag30 负

js 分享 运动框架

原文:http://www.cnblogs.com/zwn-lucky7/p/6832962.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!