简体   繁体   English

CSS animation 不适用于 Z1BDF605991920DB11ZCBDF8508204CEB4 中的 SVG 图像

[英]CSS animation not working on SVG image in iOS devices

I have one SVG image and I have added animation on it using CSS it works fine in Chrome and Mozilla, and also on Android but not working on iOS both Chrome and Safari. I have one SVG image and I have added animation on it using CSS it works fine in Chrome and Mozilla, and also on Android but not working on iOS both Chrome and Safari.

The problem is that I can see the image displayed but the animation spinning is not working.问题是我可以看到显示的图像,但 animation 旋转不起作用。

I have the following animation applied to my simple SVG:我将以下 animation 应用于我的简单 SVG:

<img class="img-sth"src="/img/image.svg">

The css code: css 代码:

.img-sth {
  position: absolute;
  height: 80px;
  top: -3px;
  left: 16px;
  -webkit-animation:spin-faster 4s linear 0.01s infinite;
  -moz-animation:spin-faster 4s linear 0.01s infinite;
  animation:spin-faster 4s linear 0.01s infinite;
}

@-moz-keyframes spin-faster { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin-faster { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin-faster { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

Below see snippet where I added the 0% {} to each @keyframes definition.下面是我在每个@keyframes定义中添加了0% {}的片段。 Your code did not work for me on macOS Safari (desktop) either when I initially tested it so I thought it may have been an issue with how the @keyframes animation was defined.当我最初测试它时,您的代码在macOS Safari (桌面)上对我不起作用,所以我认为这可能是@keyframes animation 的定义方式存在问题。 See MDN docs for more info .有关更多信息,请参阅 MDN 文档

I used a placeholder image for the demo and tweaked the positioning so it was all in the viewport.我为演示使用了占位符图像并调整了位置,使其全部在视口中。

 .img-sth { position: absolute; height: 80px; top: 20px; left: 20px; -webkit-animation:spin-faster 4s linear 0.01s infinite; -moz-animation:spin-faster 4s linear 0.01s infinite; animation:spin-faster 4s linear 0.01s infinite; } @-moz-keyframes spin-faster { 0% {} 100% { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin-faster { 0% {} 100% { -webkit-transform: rotate(360deg); } } @keyframes spin-faster { 0% {} 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
 <img class="img-sth"src="https://via.placeholder.com/80x80">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM