css 实现在一条线上流动小物体(offset-path)

直接贴代码,留几个参考网址给大家
【SVG】路径<Path>标签详解,一次搞懂所有命令参数
探秘神奇的运动路径动画 Motion Path

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    .mainater {
      width: 200px;
      height: 200px;
    }
    .g-svg {
        position: absolute;
        /* top: 50%;
        left: 50%;
        transform: translate(-50%, -50%); */
    }
    .g-wrap {
        position: relative;
        width: 200px;
        height: 200px;
        margin: auto;
    }
    .ball {
        position: aboslute;
        width: 6px;
        height: 4px;
        /* clip-path: polygon(0 0, 100% 50%, 0 100%); */
        offset-path: path('M 0 0 L 0 100 L 0 180 S 1 198 20 200 L 100 200 L 200 200');
        background: #0AC185FF;
        animation: move 3000ms infinite linear;
    }
    @keyframes move {
        0% {
            offset-distance: 0%;
        }
        100% {
            offset-distance: 100%;
        }
    }
  </style>
  <title>Document</title>
</head>
<body>
  <div class="mainater">
    <div style="scale: 1;">
      <svg class="g-svg" width="200" height="200" xmlns="http://www.w3.org/2000/svg">
        <path d="M 0 0 L 0 100 L 0 180 S 1 198 20 200 L 100 200 L 200 200" stroke="#0AC185FF" fill="none" stroke-width="2"/>
      </svg>
      <div class="g-wrap">
          <div class="ball"></div>
      </div>
    </div>
  </div>
</body>
</html>

有需求,欢迎探讨

相关推荐
Dontla1 小时前
n8n飞书webhook配置(飞书机器人、飞书bot、feishu bot)Crypto节点、js timestamp代码、Crypto node
javascript·机器人·飞书
tager2 小时前
🔥3行代码搞定全局代理!告别插件依赖的极简方案
前端·fiddler·charles
gnip3 小时前
axios 拦截器实现用户无感刷新 access_token
前端
程序员码歌4 小时前
【零代码AI编程实战】AI灯塔导航-成果展示篇
前端·ai编程·cursor
gnip4 小时前
前端实现即时通讯,常用的技术
前端
烛阴4 小时前
告别 any!用联合类型打造更灵活、更安全的 TS 代码
前端·typescript
excel5 小时前
全面解析 JavaScript 类继承:方式、优缺点与应用场景
前端
用户21411832636025 小时前
dify案例分享-100% 识别率!发票、汇票、信用证全搞定的通用票据识别工作流
前端
Hello.Reader6 小时前
Elasticsearch JS 客户端子客户端(Child Client)实践指南
大数据·javascript·elasticsearch
拾光拾趣录6 小时前
基础 | HTML语义、CSS3新特性、浏览器存储、this、防抖节流、重绘回流、date排序、calc
前端·面试