【发布时间】:2014-06-09 18:40:56
【问题描述】:
我想使用 jQuery 为背景图像幻灯片放映使用 css 过渡。 是否可以在不淡化 div 内容的情况下这样做? 如果是这样,如何?请帮忙。 这是我到目前为止没有转换的代码:
jQuery(window).load(function(){
var images = ['images/slide1.jpg','images/slide3.jpg','images/slide4.jpg','images/slide5.jpg','images/slide7.jpg',];
var i = 0;
var timeoutVar;
function changeBackground() {
clearTimeout(timeoutVar); // just to be sure it will run only once at a time
jQuery('#page').css('background-image', function() {
if (i >= images.length) {
i=0;
}
return 'url(' + images[i++] + ')';
});
// call the setTimeout every time to repeat the function
timeoutVar = setTimeout(changeBackground, 5000);
}
// Call it on the first time and it will repeat
changeBackground();
});
【问题讨论】:
标签: jquery slideshow css-transitions