javascript - 顺序图像从文件夹中的图像淡出

标签 javascript jquery html css

我的目标:

我想从文件夹中淡出每个图像。图像每隔一段时间就会改变一次。出于安全原因,这甚至可能吗?显示图像的站点不公开。仅供西博数字标牌使用

到目前为止我得到了什么:

这是 JSFiddle

HTML:

<div id="cf4a" class="shadow">
  <img src="images/4.jpg">
  <img src="images/5.jpg">
  <img src="images/4.jpg">
  <img src="images/5.jpg">
</div>

CSS:

@-webkit-keyframes cf4FadeInOut {
 0% {
   opacity:1;
 }
 17% {
   opacity:1;
 }
 25% {
   opacity:0;
 }
 92% {
   opacity:0;
 }
 100% {
   opacity:1;
 }
}

@-moz-keyframes cf4FadeInOut {
 0% {
   opacity:1;
 }
 17% {
   opacity:1;
 }
 25% {
   opacity:0;
 }
 92% {
   opacity:0;
 }
 100% {
   opacity:1;
 }
}

@-o-keyframes cf4FadeInOut {
 0% {
   opacity:1;
 }
 17% {
   opacity:1;
 }
 25% {
   opacity:0;
 }
 92% {
   opacity:0;
 }
 100% {
   opacity:1;
 }
}

@keyframes cf4FadeInOut {
 0% {
   opacity:1;
 }
 17% {
   opacity:1;
 }
 25% {
   opacity:0;
 }
 92% {
   opacity:0;
 }
 100% {
   opacity:1;
 }
}

#cf4a img {
  position:absolute;
  left:0;
}

#cf4a img {
  -webkit-animation-name: cf4FadeInOut;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-duration: 8s;

  -moz-animation-name: cf4FadeInOut;
  -moz-animation-timing-function: ease-in-out;
  -moz-animation-iteration-count: infinite;
  -moz-animation-duration: 8s;

  -o-animation-name: cf4FadeInOut;
  -o-animation-timing-function: ease-in-out;
  -o-animation-iteration-count: infinite;
  -o-animation-duration: 8s;

  animation-name: cf4FadeInOut;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-duration: 8s;
}
#cf4a img:nth-of-type(1) {
  -webkit-animation-delay: 6s;
  -moz-animation-delay: 6s;
  -o-animation-delay: 6s;
  animation-delay: 6s;
}
#cf4a img:nth-of-type(2) {
  -webkit-animation-delay: 4s;
  -moz-animation-delay: 4s;
  -o-animation-delay: 4s;
  animation-delay: 4s;
}
#cf4a img:nth-of-type(3) {
  -webkit-animation-delay: 2s;
  -moz-animation-delay: 2s;
  -o-animation-delay: 2s;
  animation-delay: 2s;
}
#cf4a img:nth-of-type(4) {
  -webkit-animation-delay: 0;
  -moz-animation-delay: 0;
  -o-animation-delay: 0;
  animation-delay: 0;
}

最佳答案

一个非常简单的解决方案可能是经常刷新页面以提取新图像。

JS:

setTimeout(function(){
   window.location.reload(1);
}, 5000);

关于javascript - 顺序图像从文件夹中的图像淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32889069/

相关文章:

html - ie 7 中的相对定位、div 堆叠问题

javascript - 导出模块包

javascript - Jcarousel 和显示 : none + SEO concern

jquery - 数据表从 DOM 中删除 CSS

javascript - 如何使用javascript更改子元素的字体大小

javascript - 大型 Html 代码 - 页面响应时间非常慢

HTML5 验证错误 a href (NFC)

javascript - 滑动面板在页面加载时显示水平滚动条

javascript - 使用JS将2个表单字段一起添加

jquery Accordion 防止冒泡/允许默认链接操作