经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS3 » 查看文章
CSS3点击按钮圆形进度打钩效果的实现代码_css3_CSS
来源:jb51  时间:2021/4/6 9:27:58  对本文有异议

文章目录 八、CSS3点击按钮圆形进度打钩效果8.1 图片预览8.2 index.html代码8.3 style.css代码


八、CSS3点击按钮圆形进度打钩效果

 8.1 图片预览

在这里插入图片描述
在这里插入图片描述

8.2 index.html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>CSS3点击按钮圆形进度打钩效果</title>
  6. <!--图标库-->
  7. <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css'>
  8. <!--核心样式-->
  9. <link rel="stylesheet" href="css/style.css">
  10. </head>
  11. <body>
  12. <div class="background">
  13. <input type="checkbox" id="button">
  14. <label for="button" class="button"> 点击按钮<i class="fas fa-check"></i></label>
  15. <svg class="circle">
  16. <circle cx="32" cy="32" r="31">
  17. </svg>
  18. </div>
  19. </body>
  20. </html>

8.3 style.css代码

  1. body {
  2. margin: 0;
  3. height: 100vh;
  4. width: 100vw;
  5. display: flex;
  6. align-items: center;
  7. justify-content: center;
  8. font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  9. font-size: 14px;
  10. }
  11.  
  12. .background {
  13. position: relative;
  14. background: linear-gradient(to top, #49b26e 0%, #57d895 100%);
  15. border-radius: 5px;
  16. display: flex;
  17. align-items: center;
  18. justify-content: center;
  19. flex-direction: column;
  20. box-shadow: 0 5px 15px 0 rgba(0, 0, 0, 0.25);
  21. width: 400px;
  22. height: 400px;
  23. color: white;
  24. }
  25.  
  26. .background input {
  27. display: none;
  28. }
  29.  
  30. .background .button {
  31. display: flex;
  32. justify-content: center;
  33. align-items: center;
  34. width: 260px;
  35. height: 60px;
  36. border: 2px solid white;
  37. border-radius: 30px;
  38. text-align: center;
  39. font-size: 20px;
  40. text-transform: uppercase;
  41. font-weight: bold;
  42. letter-spacing: 2px;
  43. transition: all 0.3s ease-in-out;
  44. cursor: pointer;
  45. }
  46.  
  47. .background .button:hover {
  48. background-color: #37be77;
  49. }
  50.  
  51. .background .button .fas {
  52. position: absolute;
  53. color: #4caf50;
  54. z-index: 2;
  55. opacity: 0;
  56. }
  57.  
  58. .background .circle {
  59. position: absolute;
  60. width: 65px;
  61. height: 65px;
  62. fill: none;
  63. stroke: white;
  64. stroke-width: 2px;
  65. stroke-linecap: round;
  66. stroke-dasharray: 183 183;
  67. stroke-dashoffset: 183;
  68. opacity: 0;
  69. left: 0;
  70. bottom: 0;
  71. right: 0;
  72. top: 0;
  73. margin: auto;
  74. pointer-events: none;
  75. transform: rotate(-90deg);
  76. }
  77.  
  78. .background input:checked~.button {
  79. animation: button 0.5s ease both, fill 0.5s ease-out 1.5s forwards;
  80. }
  81.  
  82. .background input:checked~.button .fas {
  83. animation: check 0.5s ease-out 1.5s both;
  84. }
  85.  
  86. .background input:checked~.circle {
  87. animation: circle 2s ease-out 0.5s both;
  88. }
  89.  
  90. @keyframes button {
  91. 0% {
  92. width: 260px;
  93. left: 70px;
  94. border-color: white;
  95. color: white;
  96. }
  97.  
  98. 50% {
  99. color: transparent;
  100. }
  101.  
  102. 100% {
  103. width: 60px;
  104. left: 170px;
  105. border-color: #45b078;
  106. background: transparent;
  107. color: transparent;
  108. }
  109. }
  110.  
  111. @keyframes circle {
  112. 0% {
  113. stroke-dashoffset: 183;
  114. }
  115.  
  116. 50% {
  117. stroke-dashoffset: 0;
  118. stroke-dasharray: 183;
  119. transform: rotate(-90deg) scale(1);
  120. opacity: 1;
  121. }
  122.  
  123. 90%,
  124. 100% {
  125. stroke-dasharray: 500 500;
  126. transform: rotate(-90deg) scale(2);
  127. opacity: 0;
  128. }
  129. }
  130.  
  131. @keyframes fill {
  132. 0% {
  133. background: transparent;
  134. border-color: white;
  135. }
  136.  
  137. 100% {
  138. background: white;
  139. }
  140. }
  141.  
  142. @keyframes check {
  143. 0% {
  144. opacity: 0;
  145. }
  146.  
  147. 100% {
  148. opacity: 1;
  149. }
  150. }

到此这篇关于CSS3点击按钮圆形进度打钩效果的文章就介绍到这了,更多相关css3圆形进度按钮内容请搜索w3xue以前的文章或继续浏览下面的相关文章,希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号