这篇文章主要介绍了svg+css或者js怎么制作打钩的动画效果,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
创新互联专注于中大型企业的网站设计制作、网站设计和网站改版、网站营销服务,追求商业策划与数据分析、创意艺术与技术开发的融合,累计客户上千,服务满意度达97%。帮助广大客户顺利对接上互联网浪潮,准确优选出符合自己需要的互联网运用,我们将一直专注高端网站设计和互联网程序开发,在前进的路上,与客户一起成长!
效果图:
html代码
打钩动画 成功
css代码
h3 {
font-family: Helvetica;
font-size: 30px;
margin-top: 20px;
color: #333;
opacity: 0;
}
input[type="checkbox"]:checked+ label ~ h3 {
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'});
$("h3").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'});
$("h3").css({'animation':'none','animation-fill-mode':'none'})
$(this).text("完成")
}
});感谢你能够认真阅读完这篇文章,希望小编分享的“svg+css或者js怎么制作打钩的动画效果”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!