JQuery循環(huán)滾動圖片代碼
更新時間:2011年12月08日 23:19:46 作者:
每次滾動的長度不要固定死,可以直接獲取圖片寬度作為滾動的長度。這樣當(dāng)你的網(wǎng)站有很多地方需要這個效果的時候一個函數(shù)就可以搞定了
復(fù)制代碼 代碼如下:
function refresh() {
var s = $(".box1");
if (!s.is(":animated"))
$(".box1").animate({ marginLeft: "0px" }, "slow", function () {
$('.box1 img:first').before($('.box1 img:last'));
$(".box1").css("margin-left", "-206px");
});
}
<div class="frame"><div class="box1"><img src="img/001.png" alt="" /><img src="img/002.png" alt="" /><img src="img/003.png" alt="" /><img src="img/004.png" alt="" /></div></div>
<button type="button"><<</button><button type="button" onclick="refresh()">>></button>
.box1
{
width:1200px;
overflow:hidden;
margin-left:-206px;
}
.frame
{
width:620px;
overflow:hidden;
}
圖片寬度默認(rèn)206px,沒設(shè)定
相關(guān)文章
基于zepto的移動端輕量級日期插件--date_picker
這篇文章主要介紹了基于zepto的移動端輕量級日期插件--date_picker,需要的朋友可以參考下2016-03-03
使用jQuery的ajax方法向服務(wù)器發(fā)出get和post請求的方法
這篇文章主要介紹了使用jQuery的ajax方法向服務(wù)器發(fā)出get和post請求的方法,需要的朋友可以參考下2017-01-01
jQuery Validation PlugIn的使用方法詳解
這篇文章主要介紹了jQuery Validation PlugIn的使用方法,需要的朋友可以參考下2015-12-12
jQuery實現(xiàn)移動端下拉展現(xiàn)新的內(nèi)容回彈動畫
這篇文章主要介紹了jQuery實現(xiàn)移動端下拉展現(xiàn)新的內(nèi)容回彈動畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-06-06

