我想制作一个幻灯片,其中图片通过渐弱淡入淡出过渡。它只是屏幕上的阴影并切换到下一张图片。
我得到了它的工作,但添加了其他浏览器webkits,它停止工作。似乎无法找到我的错误..幻灯片仍然有效。
这是代码:
/* Fading animation in css */
.fade {
-webkit-animation-name: fade 5s;
animation-name: fade 5s;
-moz-animation: fade 5s;
-o-animation: fade 5s;
}
@-webkit-keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100% {opacity:0.2}
}
@-moz-keyframes fade{
0% {opacity: 0.2}
50% {opacity: 1}
100% {opacity:0}
}
@keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100%{opacity: 0.2}
}
@-o-keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100%{opacity: 0.2}
}
<div class="slideshowcontainer">
<div class="slideshow fade">
<img src="images/PSA.PNG">
</div>
<div class="slideshow fade">
<img src="images/OWSA.PNG">
</div>
<div class="slideshow fade">
<img src="images/CEAC.PNG">
</div>
答案 0 :(得分:3)
只需将.fade
类修改为此
.fade {
-webkit-animation: fade 5s;
animation: fade 5s;
-moz-animation: fade 5s;
-o-animation: fade 5s;
}
因为animation-name
不期望时间间隔,所以它只需要名称。
.fade {
-webkit-animation: fade 5s;
animation: fade 5s;
-moz-animation: fade 5s;
-o-animation: fade 5s;
}
@-webkit-keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100% {opacity:0.2}
}
@-moz-keyframes fade{
0% {opacity: 0.2}
50% {opacity: 1}
100% {opacity:0}
}
@keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100%{opacity: 0.2}
}
@-o-keyframes fade {
0% {opacity: 0.2}
50% {opacity: 1}
100%{opacity: 0.2}
}
&#13;
<div class="slideshowcontainer">
<div class="slideshow fade">
<img src="https://images-na.ssl-images-amazon.com/images/I/71%2BmEwFaoaL._SL1500_.jpg" width="200px" height: "200px">
</div>
</div>
&#13;
答案 1 :(得分:3)
您只需更改属性名称
即可来自
.fade {
-webkit-animation-name: fade 5s;
animation-name: fade 5s;
-moz-animation: fade 5s;
-o-animation: fade 5s;
}
到
.fade {
-webkit-animation: fade 5s;
animation: fade 5s;
-moz-animation: fade 5s;
-o-animation: fade 5s;
}
答案 2 :(得分:0)
animation-name
不会花费几秒钟,只需要名字。将animation-name
更改为animation
。