首页 > 其他 > 详细

svg

时间:2019-01-03 20:35:59      阅读:157      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        svg{
            width: 500px;
            height: 500px;
            border:1px solid red;
        }
        #s line:nth-of-type(2){
            stroke-dasharray: 100,100;
            stroke-dashoffset: 100;
        }
    </style>
</head>
<body>
    <svg id="s">
       <line x1="0" y1="5" x2="100" y2="5" stroke="purple" stroke-width="10" />
       <line x1="0" y1="5" x2="100" y2="5" stroke="red" stroke-width="10" />
    </svg>
</body>
<script>
    var l=document.querySelector("#s line:nth-of-type(2)");
    var timer=null;
    var i=100;
    function fn(){
        timer=requestAnimationFrame(function(){
            i--; 
            l.style.strokeDashoffset=i;
            console.log(i);
            if(i>0){
                fn();
            }
        })
    }
    fn();
</script>
</html>

 

svg

原文:https://www.cnblogs.com/bao2333/p/10216590.html

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