0
我的圖像滑塊起作用,除了第一次圖像旋轉時,一個圖像突然出現。在下面的通行證是光滑的?幻燈片顯示淡入淡出效果正在加深
Javascript代碼。
var imgArray = [
'about.jpg',
'about2.jpg',
'about3.jpg'],
curIndex = 0;
imgDuration = 5000;
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();
CSS代碼。
#slider {
opacity:1;
transition: opacity 1s;
float:left;
max-width:100%;
height:auto;
margin-right:20px;
border-radius:4px 4px 4px 4px;
border-color:#CCC;
border-style:ridge;
border-width:2px;
}
#slider.fadeOut {
opacity:0;
}
我的網站。 See the effect on my site
這是唯一涉及的html。
img id="slider" src="images/other-images/blank.jpg"
您可以在適當的位置查看網站。 Test Site
克里斯使用你的代碼,沒有圖像顯示。我沒有發佈這個HTML,不知道它是否改變了什麼? – kenerly
三重檢查的文件位置,也使用當前的代碼(我發佈的)圖像顯示。爲您的代碼使用相同的路徑,但沒有圖像。我非常感謝所有幫助... – kenerly