大致上程式碼設定如下
.result_item {
float: left;
margin: 20px auto;
position: relative;
overflow: hidden;
width: 580px;
height: 270px;
text-align: center;
}
.result_item .items {
position: absolute;
width: 20000em;
clear: both;
}
.result_item .mypic {
border: 2px solid #dddddd;
width: 150px;
height: 235px;
line-height: 20px;
margin-right: 10px;
padding: 15px;
font-size: 14px;
color: #333333;
float: left;
}
<div class="result_item">
<div class="items"></div>
</div>
一開始進頁面會getData();
將15個
<div class="mypic"><img src="" alt="" />圖片一</div>
<div class="mypic"><img src="" alt="" />圖片二</div>
<div class="mypic"><img src="" alt="" />圖片三</div>
.
.
.
的資料代進$(".items")內
變成
<div class="result_item">
<div class="items">
<div class="mypic"><img src="" alt="" />圖片一</div>
<div class="mypic"><img src="" alt="" />圖片二</div>
<div class="mypic"><img src="" alt="" />圖片三</div>
.
.
.
<div class="mypic"><img src="" alt="" />圖片十五</div>
</div>
</div>
然後執行showPic();
讓它每五秒會跑一次
var t = 6;
function showPic(){
$(".result_item").scrollable({
size: 3,
circular: true,
speed: 1000
});
t -= 1;
if( t == 0 ){
var scrollable = $(".result_item").scrollable();
scrollable.next();
t = 6;
}
setTimeout("showTime()",1000);
}
主要問題在於我有設置circular: true了,
可是卻不會無限迴圈一直秀圖片,
15張跑完就停住了,
不知道問題是出在哪呢?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.163.12.174
※ 編輯: Leocancer 來自: 118.163.12.174 (09/14 19:02)