码迷,mamicode.com
首页 > 其他好文 > 详细

分享按钮demo源码

时间:2014-07-13 08:01:17      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:style   os   width   art   cti   io   

<style>
        *{margin:0;padding:0;}
        #div1{width:150px;height:200px;position:absolute;top:0px;left:-150px;background:yellow;}
        #div1 span{width:20px;heigth:70px;background:green;right:-20px;top:70px;display:block;position:absolute;}
    </style>
    <div id="div1"><span id="span1">分享到</span></div>
    <script>
    window.onload=function(){
        var oDiv1 = document.getElementById(‘div1‘);
        var oSpan = document.getElementById(‘span1‘);
        oDiv1.onmouseover=function(){
           startMove(10,0);
        }

        oDiv1.onmouseout=function(){
            startMove(-10,-150);
        }
    }
    //定义方法
    var timer = null;
    function startMove(speed,iTarget){
       var oDiv1 = document.getElementById(‘div1‘);
       var oSpan = document.getElementById(‘span‘);
       clearInterval(timer);
       timer = setInterval(function(){
            if(oDiv1.offsetLeft==iTarget){
                clearInterval(timer);
            }else{
                oDiv1.style.left = oDiv1.offsetLeft+speed+‘px‘;
            }
       },30)
    }
 
    </script>

分享按钮demo源码,布布扣,bubuko.com

分享按钮demo源码

标签:style   os   width   art   cti   io   

原文地址:http://www.cnblogs.com/jewave/p/3838051.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!