http://jsfiddle.net/pdb4kb1a/2/CSS3幻燈片淡出效果不工作
代碼工作的的jsfiddle就好了,但我不能讓它的工作,當我在一個HTML/CSS文件中使用它。只顯示50x200圖像,沒有簡單的幻燈片或淡入淡出效果的跡象。我在Sublime文本中工作,是否會產生任何問題?
var imgArray = [
'http://placehold.it/300x200',
'http://placehold.it/200x100',
'http://placehold.it/400x300'],
curIndex = 0;
imgDuration = 3000;
function slideShow() {
document.getElementById('slider').className += "fadeOut";
setTimeout(function() {
document.getElementById('slider').src = imgArray[curIndex];
document.getElementById('slider').className = "";
},1000);
curIndex++;
if (curIndex == imgArray.length) { curIndex = 0; }
setTimeout(slideShow, imgDuration);
}
slideShow();
#slider {
opacity:1;
transition: opacity 1s;
}
#slider.fadeOut {
opacity:0;
}
<body>
<img id="slider" src="http://placehold.it/50x200">
</body>
控制檯是否顯示任何錯誤?向我們展示您製作的HTML文件? – Script47
這裏看起來像它的工作正常。你的HTML文件中的JavaScript? – andreas