[英]CSS - transform: rotateX animation not working on mobile browsers (even with -webkit-)
I got an animation on my page , where a word is rotating. 我在页面上看到一个动画,其中一个单词在旋转。 Thats done with this CSS keyframe animation using
transform:rotateX(90deg)
: 通过使用
transform:rotateX(90deg)
来完成此CSS关键帧动画的操作:
.words .active{
display:inline-block;
-webkit-transform-origin: 50% 55%;
-moz-transform-origin: 50% 55%;
-ms-transform-origin: 50% 55%;
-o-transform-origin: 50% 55%;
transform-origin: 50% 55%;
-webkit-animation:ueli 3s forwards;
-moz-animation:ueli 3s forwards;
-ms-animation:ueli 3s forwards;
-o-animation:ueli 3s forwards;
animation:ueli 3s forwards;
}
@-webkit-keyframes ueli{
0%{
opacity:0;
-webkit-transform:rotateX(-90deg);
}
50%{
-webkit-transform:rotateX(0deg);
opacity:1;
}
100%{
-webkit-transform:rotateX(90deg);
opacity:0;
}
}
@keyframes ueli{
0%{
opacity:0;
transform:rotateX(-90deg);
}
50%{
transform:rotateX(0deg);
opacity:1;
}
100%{
transform:rotateX(90deg);
opacity:0;
}
}
I've read on another question , that on iOS every browser uses webkit, because they are based on uiwebview. 我读过另一个问题 ,在iOS上,每个浏览器都使用webkit,因为它们基于uiwebview。 So I added webkit to my animation.
所以我在动画中添加了webkit。 But it's still not working on mobile devices.
但是它仍然无法在移动设备上运行。
On caniuse.com I tested, if the transform property even is supported on mobile and yes, it is. 我在caniuse.com上进行了测试,是否即使移动设备也支持transform属性,是的。 So that can't be the problem I guess.
所以我猜那不是问题。 Anyone knows how I can fix that?
有人知道我该如何解决吗?
Thanks in advance! 提前致谢!
Possible solution #1 可能的解决方案#1
Try using this: 尝试使用此:
-webkit-animation-name: ueli;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
instead of 代替
-webkit-animation:ueli 3s forwards;
This could fix your problem. 这可以解决您的问题。
Possible solution #2 可能的解决方案2
Try using a different name for each browser keyframe. 尝试为每个浏览器关键帧使用不同的名称。
-webkit-animation: webkit-ueli 3s forwards;
animation:ueli 3s forwards;
And 和
@-webkit-keyframes webkit-ueli{
@keyframes ueli{
Possible solution #3 可能的解决方案#3
"Note: This property must be used together with the transform property." “注意:此属性必须与transform属性一起使用。”
Try adding a transform outside the keyframe. 尝试在关键帧之外添加变换。 W3schools ref
W3schools参考
Try this code 试试这个代码
In your style.css -webkit-keyframes
is written wrong 在您的style.css
-webkit-keyframes
中写错了
@-webkit-keyframes ueli {
0% {
opacity: 0;
transform: rotateX(-90deg);
}
50% {
transform: rotateX(0deg);
opacity: 1;
}
100% {
transform: rotateX(90deg);
opacity: 0;
}
}
@keyframes ueli {
0% {
opacity: 0;
-webkit-transform: rotateX(-90deg);
}
50% {
-webkit-transform: rotateX(0deg);
opacity: 1;
}
100% {
-webkit-transform: rotateX(90deg);
opacity: 0;
}
}
change it to 更改为
@-webkit-keyframes ueli {
0% {
opacity: 0;
-webkit-transform: rotateX(-90deg);
}
50% {
-webkit-transform: rotateX(0deg);
opacity: 1;
}
100% {
-webkit-transform: rotateX(90deg);
opacity: 0;
}
}
@keyframes ueli {
0% {
opacity: 0;
transform: rotateX(-90deg);
}
50% {
transform: rotateX(0deg);
opacity: 1;
}
100% {
transform: rotateX(90deg);
opacity: 0;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.