最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
svg+css或者js制作打钩的动画效果代码
时间:2022-06-25 14:06:52 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下svg+css或者js制作打钩的动画效果代码,对大家学习css有一定的帮助,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
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;
line-
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-
flex-direction: column;
}
写到这里本来应该就结束了,但是我们在真正实现功能的时候不太可能用,checkbox切换动画效果的显示,一般还是需要按钮操作动画效果,下面是jq操作的代码。
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("完成")
}
});
相关文章
- 热门成品短视频app下载推荐-精选成品短视频app合集 12-25
- 抖漫下载安装安卓最新版-抖漫动漫app免费版官方下载 12-25
- 国产在线视频免费观看神器-国产追剧必备APP最新榜单 12-25
- 抖漫动画app官方正版下载安装最新版本-抖漫动漫官网免费下载安卓苹果版 12-25
- 深鸢塞弭特怎么搭配阵容 12-25
- 千机阵嬴政斩将流怎么搭配 12-25
