如何为LOGO实现4个圆圈依次出现后结束的涟漪动画效果
涟漪动画实现方案
核心修改说明
- 取消默认的无限循环配置,动画仅执行1次
- 新增
animation-fill-mode: forwards属性,保证动画结束后停留在最后一帧的完全展示状态 - 调整动画关键帧逻辑,删除末尾涟漪消失的配置,保持完全展开后的视觉效果
- 调整动画时长与延迟配比,保证4个涟漪从内到外依次展开的节奏
- 补充外层相对定位容器,避免绝对定位元素布局偏移

修改后完整代码
CSS代码
html, body { color: #2E4453; font-size: 100%; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-weight: 400; background-color: #D1C4E9; margin: 0; padding: 0; height: 100vh; display: flex; align-items: center; justify-content: center; } .open-dev-radar { position: relative; width: 400px; height: 400px; } .open-dev-badge { position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); width: 90px; height: 90px; border-radius: 50%; background-color: #fff; box-shadow: 1px 2px 7px rgba(0, 0, 0, 0.34); z-index: 10; display: flex; align-items: center; justify-content: center; } .gt-dev { position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } .gt-dev:after { content: ''; position: absolute; left: 0; right: 0; top: 0; bottom: 0; -webkit-transform: scale(0); -ms-transform: scale(0); transform: scale(0); border-radius: 50%; border: solid 1px rgba(103, 58, 183, 0.74); background-image: -webkit-radial-gradient(circle farthest-corner, rgba(103, 58, 183, 0) 52%, rgba(103, 58, 183, 0.62) 100%); background-image: radial-gradient( circle farthest-corner, rgba(103, 58, 183, 0) 52%, rgba(103, 58, 183, 0.62) 100%); -webkit-animation-duration: 0.8s; animation-duration: 0.8s; -webkit-animation-name: pulse; animation-name: pulse; -webkit-animation-iteration-count: 1; animation-iteration-count: 1; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; opacity: 0; filter: alpha(opacity=0); } .gt-dev:nth-child(4) { width: 120px; height: 120px; } .gt-dev:nth-child(3) { width: 190px; height: 190px; } .gt-dev:nth-child(3):after { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; } .gt-dev:nth-child(2) { width: 270px; height: 270px; } .gt-dev:nth-child(2):after { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } .gt-dev:nth-child(1) { width: 370px; height: 370px; } .gt-dev:nth-child(1):after { -webkit-animation-delay: 0.6s; animation-delay: 0.6s; } @-webkit-keyframes pulse { 0% { -webkit-transform: scale(0); transform: scale(0); opacity: 0; filter: alpha(opacity=0); } 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; filter: alpha(opacity=100); } } @keyframes pulse { 0% { -webkit-transform: scale(0); transform: scale(0); opacity: 0; filter: alpha(opacity=0); } 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 0.7; filter: alpha(opacity=70); } }
HTML代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Ripple Animation</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="open-dev-radar"> <div class="gt-dev"></div> <div class="gt-dev"></div> <div class="gt-dev"></div> <div class="gt-dev"></div> <div class="open-dev-badge"><img src="Loader.svg" alt="LOGO"></div> </div> </body> </html>
内容的提问来源于stack exchange,提问作者Nickos
相关产品推荐
相关产品推荐

