x
 
<!DOCTYPE html>
<html>
<head>
<style>
  #frameDiv {
    width: 400px;
    height: 170px;
    margin: 20px;
    position: relative;
    border: solid black 1px;
    background-color: rgb(205, 242, 205);
  }
  img {
    position: absolute;
    z-index: 1;
    width: 70px;
    /* 使用 offset 简写属性定义路径、距离和旋转: */
    offset: path('M 50 80 C 150 -20 250 180 350 80') 150px auto 45deg;
    /* 动画持续 4 秒,延迟 1 秒,重复 3 次: */
    animation: moveImg 4s 1s 3;
  }
  svg {
    position: absolute;
    height: 100%;
    width: 100%;
    left: 0;
    top: 0;
  }
  @keyframes moveImg {
    /* 动画结束时,偏移距离达到100% */
    100%  { offset-distance: 100%; }
  }
</style>
</head>
<body>
<h1>offset 属性</h1>
<div id="frameDiv">
  <img src="/i/css/fish.svg" alt="fish"> <!-- 鱼的图片 -->
  <svg fill="none" stroke="gray" stroke-width="2" stroke-dasharray="5,5">
    <path d="M 50 80 C 150 -20 250 180 350 80" /> <!-- 路径的 SVG 图形 -->
  </svg>
</div>
<p>在这里,使用了 offset 简写属性来定义 offset-path(偏移路径)、offset-distance(偏移距离)和 offset-rotate(偏移旋转)的属性值。鱼从路径起点 150 像素的位置开始移动,并在其默认旋转角度上增加了 45 度。</p>
</body>
</html>