一位被互联网耽误的文艺青年

有人说,生命是晚霞衬红日,青松立峭壁,万里黄沙落秋雁,三月阳春映白雪,是金刀宝马,是银貂美酒,是皓月清歌的漂泊……

JQ+CSS 变换背景图时加上动态效果

JQ+CSS 变换背景图时加上动态效果

<script>

function startAutoPlay(){
var index=0;
var arr=new Array(‘../images/banner1.jpg’,’../images/banner2.jpg’,’../images/banner3.jpg’);
timer = setInterval(function(){
if(index>2){
index = 0;
}
$(‘.main-banner’).css(‘background’,’url(‘+ arr[index] +’)no-repeat top center’);
index++;
},3000);
}
startAutoPlay();
</script>

 

 

.main-banner{
background-size:cover !important; //背景拉升
transition-duration: 0.8s; //重要,场景过度效果,IE9以下不支持
/* 以下三值为默认值 */
transition-property: all;
transition-timing-function: ease;
transition-delay: 0s;
}

 

<div class=”main-banner”></div>

oldmyth