CSS Animation rotate3d not working in Safari

陌路散爱 提交于 2019-12-11 16:37:20

问题


I cannot get this animation to work in Safari 12 no matter what I try. I've tried vendor prefixes and all, but nothing works.

It works fine in Chrome. Anyone have any ideas?

<div class="spinners"></div>

This is the css:

@keyframes spinx {
  0% {
    transform: rotate3d(0, 1, 1, 360deg);
  }
  100% {
    transform: rotate3d(0, 0, 0, 360deg);
  }
}
.spinners {
  display: block;
  width: 100%;
  height: 4rem;
  overflow: hidden;
  position: relative;
}
.spinners:before, .spinners:after {
  content: "";
  width: 4rem;
  height: 4rem;
  border: 3px solid red;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -2rem 0 0 -2rem;
  display: block;
  transform-origin: 50% 50% 0;
}
.spinners:before {
  animation: spinx 2s infinite linear;
}
.spinners:after {
  border-color: blue;
  animation: spinx 4s infinite linear alternate;
}

Here's a demo: https://codepen.io/Skinner927/pen/vVEdag


回答1:


Seems like both Safari and Firefox don't recognise the change between the two key frames. To solve this you can use an intermediate keyframe:

50% {
  transform: rotate3d(0, 1, 1, 180deg);
}

Demo:

@keyframes spinx {
  0% {
    transform: rotate3d(0, 1, 1, 360deg);
  }
  50% {
    transform: rotate3d(0, 1, 1, 180deg);
  }
  100% {
    transform: rotate3d(0, 0, 0, 0);
  }
}

.spinners {
  display: block;
  width: 100%;
  height: 4rem;
  overflow: hidden;
  position: relative;
}

.spinners:before,
.spinners:after {
  content: "";
  width: 4rem;
  height: 4rem;
  border: 3px solid red;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -2rem 0 0 -2rem;
  display: block;
  transform-origin: 50% 50% 0;
}

.spinners:before {
  animation: spinx 2s infinite linear;
}

.spinners:after {
  border-color: blue;
  animation: spinx 4s infinite linear alternate;
}
<div class="box">
  <div class="spinners"></div>
</div>


来源:https://stackoverflow.com/questions/52571632/css-animation-rotate3d-not-working-in-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!