简单脉冲动画效果实现

简单脉冲动画效果实现

效果展示

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;
  }
}

完整代码下载

完整代码下载

相关推荐
KaMeidebaby3 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
nuIl3 小时前
实现一个 Coding Agent(3):工具调用
前端·agent·cursor
nuIl4 小时前
实现一个 Coding Agent(4):ReAct 循环
前端·agent·cursor
nuIl4 小时前
实现一个 Coding Agent(1):一次 LLM 调用
前端·agent·cursor
nuIl4 小时前
实现一个 Coding Agent(2):让 LLM 流式响应
前端·agent·cursor
copyer_xyf4 小时前
Python 异常处理
前端·后端·python
sugar__salt4 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
独特的螺狮粉4 小时前
篮球集训班器具管理系统 - 鸿蒙PC Electron框架完整技术实现指南
前端·javascript·华为·electron·前端框架·开源·鸿蒙
pusheng20254 小时前
IFSJ全英文专访:中国创新力量重塑先进气体感知技术,赋能全球关键基础设施安全
前端·网络·人工智能·物联网·安全
AI_零食5 小时前
番茄钟鸿蒙PC Electron框架完成:状态机、定时器管理与专注力工具设计
前端·javascript·华为·electron·开源·鸿蒙·鸿蒙系统