本文實例為大家分享了js實現圖片無縫循環輪播的具體代碼,供大家參考,具體內容如下
代碼如下
Document#container{
overflow:hidden;
width:400px;
height:300px;
margin:auto;
}
#front,#container{
display:flex;
flex-direction:row;
}
#container img{
width:400px;
height:300px;
}

front.style="position:relative;left:0px;";
back.style="position:relative;left:0px;";
setInterval(moveimg,100);
var fleft,bleft;
function moveimg(){
fleft = parseInt(front.style.left);
bleft = parseInt(back.style.left);
if(fleft == -1600){
front.style.left = 400+"px";
fleft = parseInt(front.style.left);
}
if(bleft == -2000) {
back.style.left = 0+"px";
bleft = parseInt(back.style.left);
}
front.style.left = (fleft-10)+"px";
back.style.left = (bleft-10)+"px";
}
更多關于輪播圖效果的專題,請點擊下方鏈接查看學習
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。