将svg图像颜色更改为渐变

时间:2016-05-25 13:45:08

标签: html css

更改此颜色enter image description here - >这个enter image description here

我必须将圆的颜色更改为渐变

<div class="loader loader--style3" title="2">
  <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="80px" height="80px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
  <path fill="#070e1a" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
    <animateTransform attributeType="xml"
      attributeName="transform"
      type="rotate"
      from="0 25 25"
      to="360 25 25"
      dur="0.6s"
      repeatCount="indefinite"/>
    </path>
  </svg>
</div>

1 个答案:

答案 0 :(得分:1)

我认为@Harry之前发布的教程已经很清楚了,但我在这里更新了你的代码并应用了样式。

只需添加线性渐变的定义,然后在圈子的fill属性上进行参考。

我不知道您想要使用的颜色到底是什么,只需将线性渐变定义的darkbluelightblue更改为自定义颜色。

&#13;
&#13;
<div class="loader loader--style3" title="2">
  <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="80px" height="80px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
  <defs>
        <linearGradient id="customGradient">
            <stop offset="95%" stop-color="#123354"/> 
            <stop offset="5%" stop-color="#070f1c"/>
        </linearGradient>
    </defs>
    
  <path fill="url(#customGradient)" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
    <animateTransform attributeType="xml"
      attributeName="transform"
      type="rotate"
      from="0 25 25"
      to="360 25 25"
      dur="0.6s"
      repeatCount="indefinite"/>
    </path>
  </svg>
</div>
&#13;
&#13;
&#13;

相关问题