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>

有需求,欢迎探讨

相关推荐
酷酷的鱼3 分钟前
Expo Router vs 原生React Native 完全对比指南
javascript·react native·react.js
桃子叔叔5 分钟前
react-wavesurfer录音组件2:前端如何处理后端返回的仅Blob字段
前端·react.js·状态模式
nie_xl8 分钟前
VS/TRAE中设置本地maven地址的方法
运维·服务器·前端
烧饼Fighting13 分钟前
统信UOS操作系统离线安装ffmpeg
开发语言·javascript·ffmpeg
LV技术派15 分钟前
适合很多公司和团队的 AI Coding 落地范式(三)
前端·ai编程·cursor
一只小bit16 分钟前
Qt 对话框全方面详解,包含示例与解析
前端·c++·qt·cpp·页面
m0_7482546617 分钟前
Angular 2 模板语法概述
前端·javascript·angular.js
专注VB编程开发20年17 分钟前
EDGE估计没有switch到frame的做法
前端·edge·vba
_oP_i25 分钟前
Chrome浏览器自动下载的AI模型文件
前端·chrome