【发布时间】:2020-12-01 02:45:38
【问题描述】:
我在 Firefox 中遇到了一个 svg 文件的问题,我可以将其归结为以下代码(原始图像有几行代码):
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="15 15 70 70">
<style type="text/css"><![CDATA[
.sun {
transform-box: fill-box;
animation-name: sun-spoke-rotate;
transform-origin: 50%;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-duration: 6s;
}
.sun path {
transform-box: fill-box;
animation-name: sun-spoke-scale;
transform-origin: 50%;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-duration: 6s;
}
@keyframes sun-spoke-scale {
0% { transform: scale(1,1) }
100% { transform: scale(.5,.5) }
}
@keyframes sun-spoke-rotate {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}
]]></style>
<g class="cloud">
<g class="sun">
<path
d="M80.029,43.611h-3.998c-1.105,0-2-0.896-2-1.999s0.895-2,
2-2h3.998c1.104,0,2,0.896,2,2S81.135,43.611,80.029,43.611z"/>
<path
d="M58.033,25.614c-1.105,0-2-0.896-2-2v-3.999c0-1.104,0.895-2,2-2c1.104,
0,2,0.896,2,2v3.999C60.033,24.718,59.135,25.614,58.033,25.614z"/>
<path
d="M42.033,41.612c0,1.104-0.896,1.999-2,1.999h-4c-1.104,
0-1.998-0.896-1.998-1.999s0.896-2,1.998-2h4C41.139,39.612,42.033,40.509,42.033,41.612z"/>
<path
d="M58.033,57.61c1.104,0,2,0.895,2,1.999v4c0,1.104-0.896,2-2,2c-1.105,
0-2-0.896-2-2v-4C56.033,58.505,56.928,57.61,58.033,57.61z"/>
<circle
style="paint-order: stroke; fill: #f0daba; stroke: #4a4f55; stroke-width: 8px"
cx="58.033"
cy="41.612"
r="7.999"/>
</g>
</g>
这在 chrome 和最新版本的 edge 中可以正常工作。当然,它在 Internet Explorer 中根本不起作用,但真正困扰我的是我在 Firefox 中也有问题。它运作良好 --- 直到我开始移动鼠标??!!然后它开始到处乱跳。我认为它与变换框有关:填充框。有什么想法吗?
【问题讨论】:
-
不要嵌套 transform-box: 填充框,Firefox 不喜欢它。
-
是的,我已经想到了。 ;-) 你知道如何在不嵌套变换框的情况下创建相同的动画吗? :-)
-
不删除嵌套工作?
-
很遗憾没有。我需要单独缩放每个辐条,然后将整个辐条轮作为一个整体旋转。这就是我嵌套它的原因。也许我错过了什么?