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

html代码

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>打钩动画</title>
</head>
<body>
<div id="d1">
<input type="checkbox" style="display: none" id="love1" />
<label for="love1" id="btn1" >完成</label>
<svg width="200px" height="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.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</html>

css代码

h2 {
font-family: Helvetica;
font-size: 30px;
margin-top: 20px;
color: #333;
opacity:;
}
input[type="checkbox"]:checked+ label ~ h2 {
animation: .6s title ease-in-out;
animation-delay: 1.2s;
animation-fill-mode: forwards;
}
.circle {
stroke-dasharray:;
stroke-dashoffset:;
}
input[type="checkbox"]:checked + label + svg .circle {
animation: circle 1s ease-in-out;
animation-fill-mode: forwards;
}
.tick {
stroke-dasharray:;
stroke-dashoffset:;
}
input[type="checkbox"]:checked + label+ svg .tick {
animation: tick .8s ease-out;
animation-fill-mode: forwards;
animation-delay: .95s;
}
@keyframes circle {
from {
stroke-dashoffset:;
}
to {
stroke-dashoffset:;
}
}
@keyframes tick {
from {
stroke-dashoffset:;
}
to {
stroke-dashoffset:;
}
}
@keyframes title {
from {
opacity:;
}
to {
opacity:;
}
}
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("完成")
}
});

 哦 对了还有一件事记得给人家UP主一键三连 (BV1ME411F7BG)

最新文章

  1. AJAX 汽车详细信息练习
  2. mysql5.7密码问题
  3. 用Qt写软件系列二:QCookieViewer(浏览器Cookie查看器)
  4. PhpStorm注册码 key license
  5. python解析smart结构数据
  6. js常用笔记
  7. 如何分析apache日志[access_log(访问日志)和error_log(错误日志)]
  8. channel bonding
  9. WAF指纹探测及识别技术
  10. Hibernate Mapping Exception:-9
  11. 基于PDO的简易ORM
  12. RunTime运行时在iOS中的应用之UITextField占位符placeholder
  13. 【笔记】Python集成开发环境——PyCharm 2018.3下载、注册、帮助文档
  14. vscode——配置git的path
  15. 目标检测(四)Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
  16. BZOJ4184:shallot(线段树分治,线性基)
  17. Solr删除managedschema
  18. sql中同一个Trigger里同时包含Insert,Update,Delete
  19. Fel表达式计算引擎学习
  20. nginx 报错: nginx: [emerg] open() &quot;/etc/nginx/nginx.conf&quot; failed (2: No such file or directory)

热门文章

  1. linux记录每次登陆的历史命令
  2. Flutter调研(1)-Flutter基础知识
  3. web博客
  4. 逆向破解之160个CrackMe —— 001(上)
  5. Java基础IO流 ,文件读取,由易至难
  6. 输入URL到浏览器显示页面的过程,搜集各方面资料总结一下
  7. AJAX 的 Ajax返回数据之前的loading等待效果(gif效果等)
  8. js 面向对象中,定义一个函数的过程
  9. 关于使用Binlog和canal来对MySQL的数据写入进行监控
  10. 使用vue cli3新建一个vue项目