5 초마다 전환 (페이드)으로 배경을 변경하고 싶습니다. 이것을 어떻게 알 수 있습니까?
아래 코드로 시도하고 가변 간격의 시간 간격을 설정할 수 있습니다.
JS
$(document).ready(function () {
var img_array = [1, 2, 3, 4, 5];
var index = 0;
var interval = 5000; //time intervalin milli second
setTimeout(function () {
$('#fullPage').animate({
backgroundColor: 'transparent'
}, 1000);
$('body').css('backgroundImage', 'url(http://1054.fleeceitout.com/sites/all/themes/jack/images/field.' + img_array[index++ % img_array.length] + '.jpg)');
$('#fullPage').delay(3000).animate({
backgroundColor: 'rgb(255,255,255)'
}, 1000);
setTimeout(arguments.callee, interval);
}, interval);
});
CSS
body {
background-image: url(field.2.jpg);
width: 100%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: 0 0;
background-attachment: fixed;
}
#fullPage {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
background-color: rgb(255, 255, 255);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다