gpt4 book ai didi

html - CSS动画,淡入淡出自动幻灯片不透明度

转载 作者:行者123 更新时间:2023-11-28 04:28:04 37 4
gpt4 key购买 nike

我想制作一个幻灯片,其中图片通过淡入淡出不透明度进行过渡。它只是在屏幕上变暗并切换到下一张图片。

我让它工作,但添加了其他浏览器 webkit,它停止工作。似乎找不到我的错误。幻灯片仍然有效。

这是代码:

/* 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>

最佳答案

只需将.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}

}
<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>

关于html - CSS动画,淡入淡出自动幻灯片不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48175922/

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