【问题标题】:Transform rotate a path inside a SVG [closed]变换旋转SVG内的路径[关闭]
【发布时间】:2020-04-18 13:26:48
【问题描述】:

当svg 移动时,我需要将#winga 围绕顶部中心原点旋转(左右)。但是我不能向任何方向旋转它。

svg {
  position: fixed;
  left: 50vw;
  top: 25px;
  width: 70%;
  height: 70%;
  animation: a01 9s;
  background: #0099cc;
}

@keyframes a01 {
  from {}
  to {
    left: 0;
  }
}

#winga {
  fill: gold;
  transform-origin: top center;
  animation: awinga 25s;
}

@keyframes awinga {
  from {};
  to {
    transform: rotate(30deg);
  }
}
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" version="1.1" viewBox="0 0 1280 720">
  <path id='winga' d="M100 0 L150 0 L150 300 L100 300 Z" />
</svg>

【问题讨论】:

    标签: svg rotation css-animations css-transforms


    【解决方案1】:

    您的代码在keyframes 中的from 之后有;。重写代码后,我找到并删除它,它现在应该可以工作了。

    svg {
      position: fixed;
      left: 50vw;
      top: 25px;
      width: 70%;
      height: 70%;
      animation: a01 9s;
      background: #0099cc;
    }
    
    @keyframes a01 {
      from {}
      to {
        left: 0;
      }
    }
    
    #winga {
      fill: gold;
      transform-origin: top center;
      animation: awinga 25s;
    }
    
    @keyframes awinga {
      from {}
      to {
        transform: rotate(30deg);
      }
    }
    <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" version="1.1" viewBox="0 0 1280 720">
      <path id='winga' d="M100 0 L150 0 L150 300 L100 300 Z" />
    </svg>

    【讨论】:

      猜你喜欢
      • 2012-11-10
      • 2014-02-19
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 2019-04-15
      • 2021-12-29
      • 1970-01-01
      • 2013-12-19
      相关资源
      最近更新 更多