• 匀速展开(侧边分享的效果)


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            div{
                100px;
                height: 200px;
                background: red;
                position: relative;
                top:300px;
                left:-100px;
            }
            span{
                30px;
                height: 80px;
                position: absolute;
                left: 100px;
                top:60px;
                border:1px solid black;
                text-align: center;
                line-height: 25px;
                
            }
        </style>
        <body>
            <div><span>分享到</span></div>
        </body>
    </html>

    <script>
         var oDiv = document.querySelector("div");
         var timer = null;
         oDiv.onmouseover = function(){
            startMove( 0 );
         }
         oDiv.onmouseout = function(){
            startMove( -100 );
         }
        
         function startMove(target){
            clearInterval( timer );
            timer = setInterval( function(){
                var speed = target - oDiv.offsetLeft>0 ? 5 : -5;
                if( oDiv.offsetLeft === target ){
                    clearInterval( timer );
                }else{
                    oDiv.style.left = oDiv.offsetLeft + speed + "px";
                }
            },30 )
        }
    </script>
  • 相关阅读:
    百度地图代码API
    3层下拉列表
    stl+数论——1247D
    数论+乱搞——cf181B
    思维+multiset优化——cf1249E
    线性基思想+贪心——cf1249C
    tarjan求强连通+缩点——cf1248E
    排序+模拟+优先队列——cf1248E
    栈+括号序列+暴力枚举——cf1248D1
    二分+贪心——cf1251D
  • 原文地址:https://www.cnblogs.com/tis100204/p/10328772.html
Copyright © 2020-2023  润新知