简单脉冲动画效果实现

简单脉冲动画效果实现

效果展示

CSS 知识点

  • CSS 变量的灵活使用
  • CSS 动画使用

页面整体结构实现

html 复制代码
<div class="pulse">
  <span style="--i: 1"></span>
  <span style="--i: 2"></span>
  <span style="--i: 3"></span>
  <span style="--i: 4"></span>
  <span style="--i: 5"></span>
  <span style="--i: 6"></span>
</div>

实现整体布局

css 复制代码
.pulse {
  position: relative;
  width: 200px;
  height: 200px;
  box-shadow: inset 0 0 40px #12b9ff, 0 0 50px #12b9ff;
  border-radius: 50%;
  border: 1px solid #12b9ff;
  background: url(./earch.jpg);
  background-size: cover;
}

.pulse span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 1px solid #12b9ff;
  border-radius: 50%;
}

使用CSS变量和动画实现脉冲效果

css 复制代码
.pulse span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 1px solid #12b9ff;
  animation: animate 6s linear infinite;
  border-radius: 50%;
  animation-delay: calc(var(--i) * -1s);
}

@keyframes animate {
  0%{
    width: 200px;
    height: 200px;
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  100% {
    width: 600px;
    height: 600px;
    opacity: 0;
  }
}

实现地球运动效果

css 复制代码
.pulse {
  position: relative;
  width: 200px;
  height: 200px;
  box-shadow: inset 0 0 40px #12b9ff, 0 0 50px #12b9ff;
  border-radius: 50%;
  border: 1px solid #12b9ff;
  background: url(./earch.jpg);
  background-size: cover;
  animation: animateEarth 30s linear infinite;
}

@keyframes animateEarth {
  0% {
    background-position-x: 0px;
  }
  100% {
    background-position-x: 2400px;
  }
}

完整代码下载

完整代码下载

相关推荐
顾安r4 小时前
11.8 脚本网页 推箱子
linux·前端·javascript·flask
玖釉-5 小时前
用 Vue + DeepSeek 打造一个智能聊天网站(完整前后端项目开源)
前端·javascript·vue.js
编程社区管理员11 小时前
React 发送短信验证码和验证码校验功能组件
前端·javascript·react.js
全马必破三12 小时前
React“组件即函数”
前端·javascript·react.js
三思而后行,慎承诺12 小时前
React 底层原理
前端·react.js·前端框架
座山雕~12 小时前
html 和css基础常用的标签和样式
前端·css·html
灰小猿12 小时前
Spring前后端分离项目时间格式转换问题全局配置解决
java·前端·后端·spring·spring cloud
im_AMBER13 小时前
React 16
前端·笔记·学习·react.js·前端框架
02苏_13 小时前
ES6模板字符串
前端·ecmascript·es6
excel13 小时前
⚙️ 一次性警告机制的实现:warnOnce 源码深度解析
前端