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>

有需求,欢迎探讨

相关推荐
欧阳天羲8 分钟前
AI 时代前端工程师发展路线
前端·人工智能·状态模式
Moment9 分钟前
从爆红到被嫌弃,MCP 为什么开始失宠了
前端·后端·面试
code2013 分钟前
microapp 通过链接区分主子应用步骤
前端
IT 行者27 分钟前
Claude Code Viewer: 打造 Web 端 Claude Code 会话管理利器
前端·人工智能·python·django
张毫洁33 分钟前
vue2项目搭建
前端·vue.js·node.js
@逆风微笑代码狗43 分钟前
148.《mobx-react-lite + TypeScript 入门实战教程(完整版)》
前端·react.js·typescript
凌览43 分钟前
充值成功,腾讯成为OpenClaw官方赞肋商
前端·javascript·后端
盐焗西兰花1 小时前
鸿蒙学习实战之路-Share Kit系列(12/17)-判断应用是否被系统分享拉起
前端·学习·harmonyos
范桂飓1 小时前
OpenClaw 指令大全
前端·人工智能·chrome
lxh01131 小时前
记忆函数题解
开发语言·javascript·ecmascript