好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

svg+css 或者js制作打钩的动画效果

之前 老板 让做一个登陆后 可以显示一个打钩的效果 百度 死活搜不到 今天在B站看到的一个视频居然有 根据需求改进了一下废话不多说先看效果!

ht ML 代码

<!DOCTY PE  html>
<html lang="en">
<head>
    < ;m eta charset="UTF-8">
    <t IT le>打钩动画</title>
</head>
<body>
<div id="d1">
    <input type="checkbox" style="dis play : none" id="love1" />
    <label for="love1" id=" BT  n1 " >完成</label>
<svg width="200px" h ei ght="200px">
    <circle r="90" class="circle" fill="none"  stroke =" # 2de540" stroke-width="10" cx="100" cy="100" stroke-linecap="round" transform="rotate(-90 100 100) " ></circle>
    <polyline  fill="none" stroke="#2de540" stroke-width="10" points="44,107 86,137 152,69" stroke-linecap="round" stroke-linejoin="round" class="tick" ></polyline>
</svg>
<h2 style="text-align:  center ;width: 200px">成功</h2>

</div>
</body>
<!--这里引入你本地的 jq -->
<script src="http://libs.b ai du .COM /jquery/2.0.0/jquery.min.js"></script>
</html>

css代码

h2 {
        font-f ami ly: Helvetica;
        font- Size:  30px;
        m arg in -t op: 20px;
        color: #333;
        opacity: 0;
    }
    input[type="checkbox"]:checked+ label ~ h2 {
        animation: .6s title ease -i n-out;
        animation-delay: 1.2s;
        animation-fill-mode: forwa rds ;
    }
    .circle {
        stroke-dasharray: 1194;
        stroke-dashoffset: 1194;
    }
    input[type="checkbox"]:checked + label + svg .circle {
        animation: circle 1s ease-in-out;
        animation-fill-mode: forwards;
    }
    .tick {
        stroke-dasharray: 350;
        stroke-dashoffset: 350;
    }
    input[type="checkbox"]:checked + label+ svg .tick {
        animation: tick .8s ease-out;
        animation-fill-mode: forwards;
        animation-delay: .95s;
    }
    @keyfr am es circle {
         From  {
            stroke-dashoffset: 1194;
        }
        to {
            stroke-dashoffset: 2388;
        }
    }
    @keyframes tick {
        f rom  {
            stroke-dashoffset: 350;
        }
        to {
            stroke-dashoffset: 0;
        }
    }
    @keyframes title {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    label {
        display: inline-block;
        height: 38px;
        width: 38px;
        line-height: 38px;
        padding: 0 18px;
        background-color: #1E9FFF;
        color: #fff;
        white -s pace: nowra p; 
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
    }
    #d1 {
        display: flex;
        justify-content: center;
        min-height: 100px;
        flex-direction: column;
    }

写到这里本来 应该 就结束了 但是我们在真正实现功能的时候 不太可能用 checkbox切换动画效果的显示 一般还是需要按钮操作动画效果 下面是jq操作的代码 其实用jq的.ani MATE ()更好一些但是我是 小白 所以就偷了个懒 (ps:好吧其实是不会)直接用. css()

JavaScript代码

  $("#btn1").on("click",function () {
       if($(this).text() === "完成"){
           $(".circle").css({'animation':'circle 1s ease-in-out','animation-fill-mode':'forwards'});
           $(".tick").css({'animation':'tick .8s ease-out','animation-fill-mode':'forwards','animation-delay':'.95s'});
           $("h2").css({'animation':'.6s title ease-in-out','animation-fill-mode':'forwards','animation-delay':'1.2s'})
           $(this).text("取消")
       }else{
           $(".circle").css({'animation':'none','animation-fill-mode':'none'});
           $(".tick").css({'animation':'none','animation-fill-mode':'none'});
           $("h2").css({'animation':'none','animation-fill-mode':'none'})
           $(this).text("完成")
       }
   });

到此这篇关于svg+css 或者 js 制作 打钩的动画效果的 文章 就介绍到这了,更多相关svg css 打钩动画内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!

总结

以上是 为你收集整理的 svg+css 或者js制作打钩的动画效果 全部内容,希望文章能够帮你解决 svg+css 或者js制作打钩的动画效果 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于svg+css 或者js制作打钩的动画效果的详细内容...

  阅读:14次