You need to enable JavaScript to run this app. 如何在SVG中心嵌入图像并实现外侧圆形路径环绕动画文字
优惠活动
大模型
产品
解决方案
定价
更多

如何在SVG中心嵌入图像并实现外侧圆形路径环绕动画文字

解决方案
  • 你的SVG画布viewBox坐标为0 0 400 400,环绕文字的圆形路径圆心为200,200、半径为60,只需要在SVG内部添加<image>标签,定位到圆心位置,设置合适的尺寸即可放在路径内侧居中展示
  • 直接把<image>标签放在<defs>之后、路径文字相关代码之前,可保证层级在文字下方不会遮挡内容
  • 额外添加了可选的旋转动画配置,可实现文字沿圆形路径循环转动的效果,按需调整参数即可
<div id="container">
  <div id="circle">
    <svg 
      version="1.1" 
      xmlns="http://www.w3.org/2000/svg" 
      xmlns:xlink="http://www.w3.org/1999/xlink" 
      x="0px" 
      y="0px" 
      width="200px" 
      height="200px" 
      viewBox="0 0 400 400" 
      enable-background="new 0 0 100 100" 
      xml:space="preserve"
    >
      <defs>
        <path id="circlePath" d=" M 200, 200 m -60, 0 a 60,60 0 0,1 120,0 a 60,60 0 0,1 -120,0 "/>
        <!-- 文字旋转动画配置 -->
        <animateTransform
          xlink:href="#textGroup"
          attributeName="transform"
          type="rotate"
          from="0 200 200"
          to="360 200 200"
          dur="10s"
          repeatCount="indefinite"/>
      </defs>
      <!-- 中心内侧图片 -->
      <image 
        x="150" 
        y="150" 
        width="100" 
        height="100" 
        href="https://svgshare.com/i/Z4d.svg" 
      />
      <circle cx="150" cy="100" r="75" fill="none"/>
      <g id="textGroup">
        <use xlink:href="#circlePath" fill="none"/>
        <text fill="#ffb605">
          <textPath xlink:href="#circlePath">Flip the Bird • Flip the Bird • </textPath>
        </text>
      </g>
    </svg>
  </div>
</div>

参数调整说明

  • 调整图片尺寸:修改<image>的width和height属性,同步调整x和y数值即可保持居中,计算公式为 x = 200 - 宽度/2、y = 200 - 高度/2
  • 调整旋转速度:修改动画配置里的dur属性值,数值越小旋转一圈的速度越快

内容的提问来源于stack exchange,提问作者Felicia Santos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 00:18:03