• SVG酷炫描边


    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <style type="text/css">


            html,body{
                 100%;
                height:100%;
                margin:0;
                padding:0;
                background-color: #e7e7e7;
            }

        </style>
    </head>
    <body>
        <svg width="300" height="300" viewBox="0 0 300 300" id="svg" xmlns="http://www.w3.org/2000/svg" style="margin-left:200px;margin-top:100px" >
        
            
        </svg>
        <div style="position: absolute; 292px;height:288px;overflow: hidden;top:104px;left:204px;">
             <img src="http://f.hiphotos.baidu.com/zhidao/pic/item/d833c895d143ad4b4c7b3e3180025aafa50f06ed.jpg" height="292px">
        </div>
    </body>
    </html>
    <script src="https://cdn.bootcss.com/snap.svg/0.4.1/snap.svg.js"></script>

    <script type="text/javascript">
        var strokeWidth=4;
        var width=300;

        var svg = Snap("#svg");


         var rect = svg.paper.rect(strokeWidth/2,strokeWidth/2,width-strokeWidth,width/2-strokeWidth).attr({
            strokeWidth:""+strokeWidth,
            stroke:"#FF1687",
            fill:"none",
            strokeLinecap:"round",
            
            strokeDasharray:width-strokeWidth*3+" "+(width*3-width+strokeWidth*3),
            strokeDashoffset:(width+strokeWidth)*1.5+""
        }),
            rect2 = svg.paper.rect(strokeWidth/2,width/2-strokeWidth/2,width-strokeWidth,width/2-strokeWidth).attr({
            strokeWidth:""+strokeWidth,
            strokeLinecap:"round",
            
            stroke:"#FF1687",
            fill:"none",
            strokeDasharray:width-strokeWidth*3+" "+(width*3-width+strokeWidth*3),
            strokeDashoffset:-strokeWidth+""
        });

        function animate(){
            rect.attr("strokeDashoffset",(width+strokeWidth)*1.5+"");
            rect2.attr("strokeDashoffset",-strokeWidth+"");
            
        rect.animate({strokeDashoffset:-width/2},500,mina.easein,function(){
            rect.animate({strokeDashoffset:-width/2-width/5},1500,function(){
                rect.animate({strokeDashoffset:-width*1.5+strokeWidth},500);
            });
        });

        rect2.animate({strokeDashoffset:-width*2-strokeWidth*2},500,mina.easein,function(){
            rect2.animate({strokeDashoffset:-width*2-width/5},1500,function(){
                rect2.animate({strokeDashoffset:-width*3-strokeWidth},500);
            });
        });
    }
        window.onload=function(){
            animate();
            setInterval(animate,3200);
        };

    </script>

  • 相关阅读:
    python time 转换&运算tips
    Web.py session用户认证
    简单的内存池实现gko_alloc
    cpp(第十章)
    cpp(第九章)
    cpp(第八章)
    cpp(第七章)
    cpp(第六章)
    cpp(第五章)
    结构中的位字段
  • 原文地址:https://www.cnblogs.com/fanjun/p/5994091.html
Copyright © 2020-2023  润新知