gpt4 book ai didi

css - 多个 CSS 过渡

转载 作者:太空宇宙 更新时间:2023-11-04 11:43:13 25 4
gpt4 key购买 nike

我在让两个转换协同工作时遇到问题。

第二个动画(部分)有效,但摆动效果似乎重置并在一段时间后停止重复,第一个动画根本不起作用。

这是我的动画代码:

.box{
width:250px; height:50px;
background:blue;
border: 1px solid black;
position:fixed;
left: 50%;
margin-left:-125px;
top:0px;

animation-name: fall;
animation-duration: 1.5s;
animation-timing-function: ease-in;

animation-name: swing;
animation-duration: 4s;
animation-iteration-count:infinte;
animation-timing-function: ease-in-out;
animation-delay: 1.4s;
}
@-moz-keyframes fall{
from {top: -50px;}
to {top: 0px;}
}
@-webkit-keyframes fall{
from {top: -50px;}
to {top: 0px;}
}
@-moz-keyframes swing{
-moz-transform-origin: center top;
0%{-moz-transform:rotate(-3deg)}
50%{-moz-transform:rotate(-2deg)}
100%{-moz-transform:rotate(-3deg)}
}
@-webkit-keyframes swing{
-webkit-transform-origin:center top;
0%{-webkit-transform:rotate(-3deg)}
50%{-webkit-transform:rotate(-2deg)}
100%{-webkit-transform:rotate(-3deg)}
}

可在此处找到显示问题的演示: http://jsfiddle.net/akwbmw86/

我在这里弄错了什么?

最佳答案

您将浏览器特定前缀与非浏览器特定前缀混合使用,同时为了指定多个动画,您只需要用逗号将它们分开。在您的示例中,跌落动画被摆动动画覆盖。

像这样:

.box{
width:250px; height:50px;
background:blue;
border: 1px solid black;
position:fixed;
left: 50%;
margin-left:-125px;
top:150px;

animation: fall 1.5s ease-in, swing 4s ease-in-out;
-webkit-animation: fall 1.5s ease-in, swing 4s ease-in-out;
-moz-animation: fall 1.5s ease-in, swing 4s ease-in-out;
}

@-moz-keyframes fall{
0% {top: -50px;}
100% {top: 150px;}
}
@-webkit-keyframes fall{
0% {top: -50px;}
100% {top: 150px;}
}
@-moz-keyframes swing{
-moz-transform-origin: center top;
0%{-moz-transform:rotate(-3deg)}
50%{-moz-transform:rotate(-2deg)}
100%{-moz-transform:rotate(-3deg)}
}
@-webkit-keyframes swing{
-webkit-transform-origin:center top;
0%{-webkit-transform:rotate(-3deg)}
50%{-webkit-transform:rotate(-2deg)}
100%{-webkit-transform:rotate(-3deg)}
}

检查 this fiddle

关于css - 多个 CSS 过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31174970/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com