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


<!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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
书写顺序的意义,减少浏览器reflow(回流),提升浏览器渲染dom的性能。解析html构建dom树,解析css构建css树:将html解析成树形的数据结构,将css解析成树形的数据结构;构建render树:DOM树和CSS树合并之后形成的render树。...
HTML中跨列属性COLSPAN用法是什么,如果你正在学习HTML,不妨都看看小编所整理的资料,希望能在工作中帮助到你。
这篇文章主要介绍了css display:box 新属性的相关资料,需要的朋友可以参考下
方法:1、利用position属性将图片元素设置为固定定位样式,语法为“图片元素{position:fixed;}”;2、利用bottom属性,将固定定位样式的图片元素固定在底部即可,语法为“图片元素{bottom:0;}”。
在css中,修改表格边框颜色的代码是“表格元素{border-color:颜色值;}”;“border-color”属性的作用就是设置元素的边框颜色,该属性值也可以分别设置四个边框的颜色。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
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核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008