zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    Microsoft Web Camp
    [程序员学英语]26个英文字母
    原来接口是这样用的!一个例子搞定接口
    BizTalk Server 2010 培训
    [PM Tools]软件项目进度跟踪表v4.0
    BizTalk 开发系列(四十一) BizTalk 2010 BAM 安装手记
    WCF服务编程HelloWorld
    BizTalk 开发系列(三十九) BizTalk Server 2009技术概览
    WCF服务编程WCF应用程序的消息跟踪
    WCF服务编程基础
  • 原文地址:https://www.cnblogs.com/fanjun/p/5994091.html
Copyright © 2011-2022 走看看