【问题标题】:keyframe animation does not work on safari for iOS关键帧动画不适用于 iOS 版 Safari
【发布时间】:2015-08-25 01:04:43
【问题描述】:

Windows 上的所有浏览器(chrome,即 firefox,safari)都按应有的方式显示动画。当我在我的 iphone 上尝试过时,动画将无法正常工作。任何想法为什么?

这是我的 CSS:

#rotatingDiv {
  position: relative;
  z-index: 0;
  display: block;
  margin: auto;
  height: 30px;
  width: 30px;
  -webkit-animation: rotation .7s infinite linear;
  -moz-animation: rotation .7s infinite linear;
  -o-animation: rotation .7s infinite linear;
  animation: rotation .7s infinite linear;
  border-left: 8px solid rgba(0, 0, 0, .20);
  border-right: 8px solid rgba(0, 0, 0, .20);
  border-bottom: 8px solid rgba(0, 0, 0, .20);
  border-top: 8px solid rgba(33, 128, 192, 1);
  border-radius: 100%;
}
@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}
@-webkit-keyframes rotation {
  from {
    -webkit-transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(359deg);
  }
}
@-moz-keyframes rotation {
  from {
    -moz-transform: rotate(0deg);
  }
  to {
    -moz-transform: rotate(359deg);
  }
}
@-o-keyframes rotation {
  from {
    -o-transform: rotate(0deg);
  }
  to {
    -o-transform: rotate(359deg);
  }
}

【问题讨论】:

  • 设备/iOS版本?在装有 iOS 8.3 的 iPhone 5s 上运行良好。

标签: css css-animations


【解决方案1】:

我带着同样的问题来到这里,然后尝试了一些有效的方法:

尝试将每个关键帧(和动画)重命名为每个浏览器前缀的唯一名称。

例如:

#rotatingDiv {
  position: relative;
  z-index: 0;
  display: block;
  margin: auto;
  height: 30px;
  width: 30px;
  /* renamed these */
  -webkit-animation: webkit-rotation .7s infinite linear; 
  -moz-animation: moz-rotation .7s infinite linear;
  -o-animation: o-rotation .7s infinite linear;
  animation: rotation .7s infinite linear;
  border-left: 8px solid rgba(0, 0, 0, .20);
  border-right: 8px solid rgba(0, 0, 0, .20);
  border-bottom: 8px solid rgba(0, 0, 0, .20);
  border-top: 8px solid rgba(33, 128, 192, 1);
  border-radius: 100%;
}
@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}
/* and renamed these accordingly */
@-webkit-keyframes webkit-rotation {
  from {
    -webkit-transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(359deg);
  }
}
@-moz-keyframes moz-rotation {
  from {
    -moz-transform: rotate(0deg);
  }
  to {
    -moz-transform: rotate(359deg);
  }
}
@-o-keyframes o-rotation {
  from {
    -o-transform: rotate(0deg);
  }
  to {
    -o-transform: rotate(359deg);
  }
}

【讨论】:

    猜你喜欢
    • 2015-01-15
    • 1970-01-01
    • 2014-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多