如何停止幻灯片放映隐藏文本和图像跳到顶部,而下一张幻灯片进来



此幻灯片同时与图像和文本完美运行,但是当您在底部滚动时出现问题,每次下一张幻灯片更改或出现时,它都会跳到顶部,不知道为什么。

这是参考链接: 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)的widthheight,例如:

#banner {
    ...
    width: 100%;
    height: 174px;
}

现在它应该可以工作了。

最新更新