用css3怎样做点击圆形按钮显示正确图片的效果?
Admin 2021-10-18 群英技术资讯 951 次浏览


<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS3点击按钮圆形进度打钩效果</title> <!--图标库--> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css'> <!--核心样式--> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="background"> <input type="checkbox" id="button"> <label for="button" class="button"> 点击按钮<i class="fas fa-check"></i></label> <svg class="circle"> <circle cx="32" cy="32" r="31"> </svg> </div> </body> </html>
body {
margin: 0;
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 14px;
}
.background {
position: relative;
background: linear-gradient(to top, #49b26e 0%, #57d895 100%);
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
box-shadow: 0 5px 15px 0 rgba(0, 0, 0, 0.25);
width: 400px;
height: 400px;
color: white;
}
.background input {
display: none;
}
.background .button {
display: flex;
justify-content: center;
align-items: center;
width: 260px;
height: 60px;
border: 2px solid white;
border-radius: 30px;
text-align: center;
font-size: 20px;
text-transform: uppercase;
font-weight: bold;
letter-spacing: 2px;
transition: all 0.3s ease-in-out;
cursor: pointer;
}
.background .button:hover {
background-color: #37be77;
}
.background .button .fas {
position: absolute;
color: #4caf50;
z-index: 2;
opacity: 0;
}
.background .circle {
position: absolute;
width: 65px;
height: 65px;
fill: none;
stroke: white;
stroke-width: 2px;
stroke-linecap: round;
stroke-dasharray: 183 183;
stroke-dashoffset: 183;
opacity: 0;
left: 0;
bottom: 0;
right: 0;
top: 0;
margin: auto;
pointer-events: none;
transform: rotate(-90deg);
}
.background input:checked~.button {
animation: button 0.5s ease both, fill 0.5s ease-out 1.5s forwards;
}
.background input:checked~.button .fas {
animation: check 0.5s ease-out 1.5s both;
}
.background input:checked~.circle {
animation: circle 2s ease-out 0.5s both;
}
@keyframes button {
0% {
width: 260px;
left: 70px;
border-color: white;
color: white;
}
50% {
color: transparent;
}
100% {
width: 60px;
left: 170px;
border-color: #45b078;
background: transparent;
color: transparent;
}
}
@keyframes circle {
0% {
stroke-dashoffset: 183;
}
50% {
stroke-dashoffset: 0;
stroke-dasharray: 183;
transform: rotate(-90deg) scale(1);
opacity: 1;
}
90%,
100% {
stroke-dasharray: 500 500;
transform: rotate(-90deg) scale(2);
opacity: 0;
}
}
@keyframes fill {
0% {
background: transparent;
border-color: white;
}
100% {
background: white;
}
}
@keyframes check {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
以上就是用css3实现点击圆形按钮显示正确图片效果的代码,有需要的朋友可以参考,希望对大家学习css3的使用有帮助,想要了解更多可以继续浏览群英网络其他相关的文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了在html页面中取得session中的值的方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
我们知道使用CSS可以实现很多特效,这篇文章就给大家分享一个使用css做一个波动水球的特效的内容,小编觉得比较有趣,实现效果及代码如下,感兴趣的朋友就继续往下看吧。
CSS属性选择器用哪个合适,基本用法是怎样?有些朋友可能对属性选择器不陌生,但面对各种类型的属性选择器却不知道用哪个比较好。为了帮助大家解决困惑,小编在此特地整理了相关资料,一起来看看吧!
这篇文章主要介绍了html table呈现个人简历以及单元格宽度失效的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
如何二次加粗文字?如何实现多重边框?下面本篇文章就来给大家介绍一下巧妙利用 CSS 实现文字二次加粗和多重边框效果,希望对大家有所帮助!
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008