此幻灯片同时与图像和文本完美运行,但是当您在底部滚动时出现问题,每次下一张幻灯片更改或出现时,它都会跳到顶部,不知道为什么。
这是参考链接: http://new.kingspointcap.com/home
下面是JS代码:
/*----------Slideshow of text------------*/
var faderIndex = 2, //to keep track, also it will start from 1st because last value is 0
faders = $('.fadeTxt'); //cache, so we won't have to walk the dom every time
function nextFade() {
//fade out element over 3000 milliseconds, after which call a function
$(faders[faderIndex]).fadeOut(6000, function () {
//increase the index and do a check, so we won't overflow
faderIndex++;
if (faderIndex >= faders.length)
faderIndex = 0;
//fade in the next element, after which call yourself infinitely
$(faders[faderIndex]).fadeIn(3000, nextFade);
});
}
//get the ball rolling
nextFade();
/*----------Slideshow of text------------*/
问题是,fadeOut
动画以 display: none;
结尾。在此fadeOut
和下一fadeIn
之间,文档较小,浏览器必须滚动。
设置包装器(带有id
横幅的div
)的width
和height
,例如:
#banner {
...
width: 100%;
height: 174px;
}
现在它应该可以工作了。