Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

css - keyframe animation does not work on safari for iOS

All the browsers (chrome, ie, firefox, safari) on windows show the animation as they should. When I have tried it on my iphone, the animation would not work. Any ideas why?

Here is my 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);
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I arrived here with the same problem, then tried something which worked :

Try renaming each of your keyframes (and animations) to something unique for every browser prefix.

eg:

#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);
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...