CSS水波纹效果

效果图:

1.创建一个div

javascript 复制代码
 <div class="point1" @click="handlePoint(1)"></div>

2.设置样式

javascript 复制代码
  .point1{
    width: 1rem;
    height: 1rem;
    background: #2ce92f;
    position: absolute;
    border-radius: 50%;
    z-index: 999;
    cursor: pointer;
  }

3.设置伪元素样式

javascript 复制代码
  .point1::after {
    width: 100%;
    height: 100%;
    content: "";
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -2;
    background-color: #2ce92f;
    animation: dot-play 4s linear 400ms infinite;
  }
  .point1::before {
    width: 100%;
    height: 100%;
    content: "";
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    background-color: #2ce92f;
    animation: dot-play 4s linear 200ms infinite;
    animation-delay: 2s; /* 延迟 2s */
  }

4.设置动画效果

javascript 复制代码
  @keyframes dot-play {
    from {
      transform: scale(1);
      opacity: 0.8;
    }
    to {
      transform: scale(4);
      opacity: 0.1;
    }
  }
相关推荐
你的人类朋友40 分钟前
什么是API签名?
前端·后端·安全
会豪3 小时前
Electron-Vite (一)快速构建桌面应用
前端
中微子3 小时前
React 执行阶段与渲染机制详解(基于 React 18+ 官方文档)
前端
唐某人丶3 小时前
教你如何用 JS 实现 Agent 系统(2)—— 开发 ReAct 版本的“深度搜索”
前端·人工智能·aigc
中微子3 小时前
深入剖析 useState产生的 setState的完整执行流程
前端
遂心_3 小时前
JavaScript 函数参数传递机制:一道经典面试题解析
前端·javascript
小徐_23333 小时前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
RoyLin3 小时前
TypeScript设计模式:适配器模式
前端·后端·node.js
遂心_4 小时前
深入理解 React Hook:useEffect 完全指南
前端·javascript·react.js
Moonbit4 小时前
MoonBit 正式加入 WebAssembly Component Model 官方文档 !
前端·后端·编程语言