栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

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

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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



html代码




    
    打钩动画



    
    

    
    

成功

css代码

h2 {
 font-family: Helvetica;
 font-size: 30px;
 margin-top: 20px;
 color: #333;
 opacity: 0;
    }
    input[type="checkbox"]:checked+ label ~ h2 {
 animation: .6s title ease-in-out;
 animation-delay: 1.2s;
 animation-fill-mode: forwards;
    }
    .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;
    }
    @keyframes circle {
 from {
     stroke-dashoffset: 1194;
 }
 to {
     stroke-dashoffset: 2388;
 }
    }
    @keyframes tick {
 from {
     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-space: nowrap;
 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的.animate()更好一些但是我是小白所以就偷了个懒 (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 打钩动画内容请搜索考高分网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/214801.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号