2015-02-09 70 views
0

这里是从我的代码示例:进行内部SVG旋转

<div style="width:100%;"> 
    <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 400 200"> 
     <svg class="a"> 
      <g> 
       <path class="area1" d="M52,5 A50,50 0 0,1 80,17" style="stroke-width:10; fill:none;" stroke="gray"/> 
       <path class="area2" d="M83,20 A50,50 0 0,1 94.5,48" style="stroke-width:10; fill:none; stroke: gray;"/>      
       <path class="area3" d="M94,52 A50,50 0 0,1 84,80" style="stroke-width:10; fill:none; stroke: gray;"/> 
       <path class="area4" d="M80,83 A50,50 0 0,1 52,95" style="stroke-width:10; fill:none; stroke: gray; "/> 
       <path class="area5" d="M48,95 A50,50 0 0,1 20,83" style="stroke-width:10; fill:none;" stroke="gray"/> 
       <path class="area6" d="M17,80 A50,50 0 0,1 5,52" style="stroke-width:10; fill:none;" stroke="gray"/> 
       <path class="area7" d="M5,48 A50,50 0 0,1 17,20" style="stroke-width:10; fill:none;" stroke="gray"/> 
       <path class="area8" d="M20,17 A50,50 0 0,1 48,5" style="stroke-width:10; fill:none;" stroke="gray"/> 
      </g> 
     </svg> 
     <svg x="80" y="80"> 
      <g> 
      <path class="area1" d="M52,5 A50,50 0 0,1 80,17" style="stroke-width:10; fill:none;" stroke="gray"/> 
      <path class="area2" d="M83,20 A50,50 0 0,1 94.5,48" style="stroke-width:10; fill:none; stroke: gray;"/>      
      <path class="area3" d="M94,52 A50,50 0 0,1 84,80" style="stroke-width:10; fill:none; stroke: gray;"/> 
          <path class="area4" d="M80,83 A50,50 0 0,1 52,95" style="stroke-width:10; fill:none; stroke: gray; "/> 
      <path class="area5" d="M48,95 A50,50 0 0,1 20,83" style="stroke-width:10; fill:none;" stroke="gray"/> 
      <path class="area6" d="M17,80 A50,50 0 0,1 5,52" style="stroke-width:10; fill:none;" stroke="gray"/> 
      <path class="area7" d="M5,48 A50,50 0 0,1 17,20" style="stroke-width:10; fill:none;" stroke="gray"/> 
      <path class="area8" d="M20,17 A50,50 0 0,1 48,5" style="stroke-width:10; fill:none;" stroke="gray"/> 
     </g> 
     </svg> 
    </svg> 
</div> 

而CSS:

.a { 
    -webkit-animation-duration: 6s; 
    -webkit-animation-iteration-count: 6; 
    -webkit-animation-timing-function: linear; 
    -webkit-animation-name: ckw; 
} 

我试图让孩子SVG的旋转,但它不工作。 如果我把父类svg放在同一个类上,它会旋转,但不是我想要的方式。 任何帮助将不胜感激。

在此先感谢。

回答

1

首先..我会清理代码;)然后添加animateTransformcircle你想旋转。

干杯!

.circle { 
 
    stroke: gray; 
 
    stroke-width: 10; 
 
    stroke-dasharray: 10; 
 
    fill: transparent; 
 
}
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 400 200"> 
 
    
 
    <circle class="circle" cx="40" cy="40" r="35"> 
 
    <animateTransform 
 
     attributeName="transform" 
 
     begin="0s" 
 
     dur="6s" 
 
     type="rotate" 
 
     from="0 40 40" 
 
     to="360 40 40" 
 
     repeatCount="indefinite" 
 
    /> 
 
    </circle> 
 
    
 
    <circle class="circle" cx="100" cy="100" r="35"/> 
 
    
 
</svg>