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>

有需求,欢迎探讨

相关推荐
ZHOUPUYU10 分钟前
PHP 现代工程实践:从语言特性到高性能 Web 应用构建
android·前端·php
Nazarick32 分钟前
从 fetch 到 then:Demo在线订单系统 Ajax 回调的逐帧拆解
java·javascript·ajax·web
zhanlang02172 小时前
1.2 CSS 盒模型深度剖析:标准与怪异模式的博弈
前端·css
徐同保2 小时前
模板里的图标组件找不到定义?聊聊 @tabler/icons-vue 与自动导入
前端·javascript·vue.js
喵本喵叁肆3 小时前
ReAct、Plan-Execute、Reflection:三种 Agent 模式实测对比
前端·react.js·前端框架
qetfw3 小时前
EVE-NG 导入 Debian 虚拟机:VMDK 转 QCOW2 与启动验证
linux·前端·debian·github
橙光成长3 小时前
GameScrcpy:不装模拟器,用键鼠手柄和 TypeScript 脚本接管你的安卓手游
android·javascript·typescript·开源·1024程序员节
这里是北京4 小时前
HLS 播放地址有效期只有5分钟,直播到一半会断吗?
运维·前端·网络
ZHOUPUYU4 小时前
PHP 实战:从零构建一个高可用的小型 Web 应用
android·前端·php
JudithHuang4 小时前
Vue3 WebSocket 实时协作
前端·网络·websocket·网络协议·vue