svg马儿奔跑动画代码

代码语言:html

所属分类:其他

代码由deepseek-4.1 ai生成,可能有错误,仅供参考:点击查看提示词

代码描述:svg马儿奔跑动画

代码标签: svg 马儿 奔跑 动画 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>奔跑的马 · SVG 动画</title>
<style>
  html, body { height: 100%; margin: 0; }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(120% 120% at 50% 25%, #2b4b63 0%, #0e1a26 75%);
  }

  svg#scene {
    display: block;
    width: 100vw;
    height: 100vh;
  }

  /* ===== 背景循环滚动(CSS 动画) ===== */
  @keyframes scrollGrass {
    from { transform: translateX(0); }
    to   { transform: translateX(-300px); }
  }
  @keyframes scrollSpeed {
    from { transform: translateX(0); }
    to   { transform: translateX(-900px); }
  }

  /* 草地:一个 300px 宽的瓦片平铺 5 份,整体左移 300px 后瞬间复位 → 无缝 */
  #grassScroll {
    animation: scrollGrass 0.8s linear infinite;
  }

  /* 速度线:整条画布左移 900px 后复位 */
  #speedScroll {
    animation: scrollSpeed 0.85s linear infinite;
  }
</style>
</head>
<body>

<svg id="scene" viewBox="0 0 900 500" preserveAspectRatio="xMidYMid meet"
     xmlns="http://www.w3.org/2000/svg">

  <!-- ================= 渐变定义 ================= -->
  <defs>
    <linearGradient id="skyGrad" x1="0" y1="0" x2="0" y2="1">
      <stop offset="0"    stop-color="#A9D9F2"/>
      <stop offset="0.55" stop-color="#DCEFF8"/>
      <stop offset="1"    stop-color="#FFF4DA"/>
    </linearGradient>

    <linearGradient id="groundGrad" x1="0" y1="0" x2="0" y2="1">
      <stop offset="0"    stop-color="#9AD47F"/>
      <stop offset="0.35" stop-color="#7CBD.........完整代码请登录后点击上方下载按钮下载查看

网友评论0