輪播中第五張圖轉(zhuǎn)第一張圖中間有閃過的空白
<body>
<div id="container">
<div id="list" style="left:-1500px">
<img src="5.png" alt="" />
<img src="1.jpg" alt="" />
<img src="2.jpg" alt="" />
<img src="3.png" alt="" />
<img src="4.png" alt="" />
<img src="5.png" alt="" />
<img src="1.png" alt="" />
我的每張圖片都在1500px左右,在輪播時(shí)只有向右點(diǎn)擊按鈕時(shí)的最后一張圖轉(zhuǎn)第一張圖會(huì)有空白閃過,而第一張圖轉(zhuǎn)最后一張卻沒有問題,點(diǎn)擊代碼如下:
function qiehuan(shuzi) {
panduan = true;
var newleft = parseInt(list.style.left) + shuzi;
var time = 300;
var jiange = 10;
var cishu = shuzi / (time / jiange);
function go() {
if ((cishu < 0 && parseInt(list.style.left) > newleft) || (cishu > 0 && parseInt(list.style.left) < newleft)) {
list.style.left = parseInt(list.style.left) + cishu + 'px';
setTimeout(go, jiange);
}
else {
panduan = false;
list.style.left = newleft + 'px';
if (newleft > -1500) {
list.style.left = -7500+ 'px';
}
if (newleft < -7585) {
list.style.left = -1500 + 'px';
}
}
}
go();
}
list父容器的代碼也如下:
#list {
position: absolute;
width: 10585px;
height: 800px;
z-index: 1;
}
#list img {
float: left;
height: auto;
width: 1500px;
}
就不明白了
2019-12-15
那就是你多給一張圖片的數(shù)值,可以減少一張圖片的數(shù)值來解決
2019-06-28
說的好像我明白一樣