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


<!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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
css Flexbox布局的介绍:1、Flexbox是flexiblebox的简称,是CSS3引进的新布局模式。2、决定了要素如何在页面上排列,可以在不同的画面尺寸和设备下预测地表现出来。
这篇文章主要介绍了html5实现可拖拽移动的悬浮图标的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
平时工作中很多场合都要用到定时器,比如延迟加载、定时查询等等,但定时器的控制有时候会有些许麻烦,比如鼠标移入停止、移出再重新开始。这次介绍几个借助 CSS 来更好的控制定时器的方法,一起了解一下吧,相信可以带来不一样的体验。
grid布局又称为网格布局,可以实现二维布局方式。这是使用CSS控制的,不是使用HTML控制的,同时还可以依赖于媒体查询根据不同的上下文得新定义布局。
下拉菜单在很多网页中都能应用到,这篇文章主要介绍了纯CSS实现的大型下拉菜单的示例代码的相关资料,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008