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>

有需求,欢迎探讨

相关推荐
云边有个稻草人32 分钟前
【Web前端技术】第二节—HTML标签(上)
前端·html·html基本结构标签·html超链接标签·html中的注释和特殊字符·vscode的使用·vscode生成骨架标签
介si啥呀~35 分钟前
解决splice改变原数组的BUG(拷贝数据)
java·前端·bug
太阳花ˉ38 分钟前
BFC详解
前端
小满zs3 小时前
React-router v7 第五章(路由懒加载)
前端·react.js
Aotman_3 小时前
Vue el-from的el-form-item v-for循环表单如何校验rules(二)
前端·javascript·vue.js
BillKu4 小时前
Vue3父子组件数据双向绑定示例
javascript·vue.js·elementui
在无清风5 小时前
Java实现Redis
前端·windows·bootstrap
_一条咸鱼_6 小时前
Vue 配置模块深度剖析(十一)
前端·javascript·面试
yechaoa7 小时前
Widget开发实践指南
android·前端
赤橙红的黄7 小时前
Spring Boot中接入DeepSeek的流式输出
java·服务器·javascript