当前位置:首页 » 手机壁纸 » js手机图片滑动
扩展阅读
女人阴真实图片迅雷下载 2024-11-27 18:34:58
哪里都不安全图片 2024-11-27 18:34:07
ps图片周围加文字 2024-11-27 18:23:15

js手机图片滑动

发布时间: 2024-07-13 10:31:02

A. js锲剧墖宸﹀彸婊氩姩 镐庝箞寮 链夋病妗堜緥浠g爜 姹傚府蹇

1.jquery.imgScroll.js

;(function($){$.fn.extend({"imgScroll":function(object){object=$.extend({firstDiv:null,scrollBox:null,scrollImgBox:null,tabDiv:null,tabDivList:null,botPrev:null,botNext:null,changeType:"slide",thumbNowClass:'on',thumbOverEvent:true,changeTime:5000,ImgBoxMar:0,flag:true},object||{});varimgLen=$(object.scrollImgBox).length;varimgNum=0;vartabNum=0;varnowIndex=0;varindex;varscrollWid=$(object.scrollImgBox).width()+object.ImgBoxMar;$(object.scrollImgBox).clone().appendTo($(this));functionchangeEffectNext(){if(object.changeType=='slide'){if(imgNum<imgLen){imgNum++}else{if(imgNum==imgLen){$(object.scrollBox).css({'margin-left':0});imgNum=1}}$(object.scrollBox).animate({'margin-left':-scrollWid*imgNum});if(tabNum<imgLen-1){tabNum++}else{if(tabNum==imgLen-1){tabNum=0}}$(object.tabDivList).eq(tabNum).addClass(object.thumbNowClass);$(object.tabDivList).eq(tabNum).siblings().removeClass(object.thumbNowClass)}if(object.changeType=='fadein'){if(imgNum<imgLen-1){imgNum++}else{if(imgNum==imgLen-1){imgNum=0}}$(object.scrollImgBox).eq(imgNum).fadeIn('slow');$(object.scrollImgBox).eq(imgNum).siblings().fadeOut('slow');$(object.tabDivList).eq(imgNum).addClass(object.thumbNowClass);$(object.tabDivList).eq(imgNum).siblings().removeClass(object.thumbNowClass)}};functionchangeEffectPrev(){if(object.changeType=='slide'){if(imgNum>0){imgNum--}else{if(imgNum==0){$(object.scrollBox).css({'margin-left':-scrollWid*imgLen});imgNum=imgLen-1}}$(object.scrollBox).animate({'margin-left':-scrollWid*imgNum});if(tabNum>0){tabNum--}else{if(tabNum==0){tabNum=imgLen-1}}$(object.tabDivList).eq(tabNum).addClass(object.thumbNowClass);$(object.tabDivList).eq(tabNum).siblings().removeClass(object.thumbNowClass)}if(object.changeType=='fadein'){if(imgNum>0){imgNum--}else{if(imgNum==0){imgNum=imgLen-1}}$(object.scrollImgBox).eq(imgNum).fadeIn('slow');$(object.scrollImgBox).eq(imgNum).siblings().fadeOut('slow');$(object.tabDivList).eq(imgNum).addClass(object.thumbNowClass);$(object.tabDivList).eq(imgNum).siblings().removeClass(object.thumbNowClass)}}if(object.flag==true){vars=setInterval(changeEffectNext,object.changeTime);$(object.firstDiv).hover(function(){clearInterval(s)},function(){s=setInterval(changeEffectNext,object.changeTime);});$(object.tabDiv).hover(function(){clearInterval(s)},function(){s=setInterval(changeEffectNext,object.changeTime)});$(object.botPrev).bind("click",function(){clearInterval(s)}).bind("mouseover",function(){clearInterval(s)});$(object.botNext).bind("click",function(){clearInterval(s)}).bind("mouseover",function(){clearInterval(s)})};$(object.botNext).click(function(){changeEffectNext()});$(object.botPrev).click(function(){changeEffectPrev()});functionchangesmallImg(index){$(object.tabDivList).eq(index).addClass(object.thumbNowClass);$(object.tabDivList).eq(index).siblings().removeClass(object.thumbNowClass);if(object.changeType=='slide'){$(object.scrollBox).animate({'margin-left':-scrollWid*index})}if(object.changeType=='fadein'){$(object.scrollImgBox).eq(index).fadeIn('slow');$(object.scrollImgBox).eq(index).siblings().fadeOut('slow')}imgNum=index;tabNum=index}if(object.thumbOverEvent==true){$(object.tabDivList).click(function(){varindex=$(this).index();changesmallImg(index)})}if(object.thumbOverEvent==false){$(object.tabDivList).hover(function(){varindex=$(this).index();changesmallImg(index)})}}})})(jQuery);

2.html缁撴瀯

a,.lbPeo{-webkit-transition:all.2sease-in-out0s;-o-transition:all.2sease-in-out0s;-moz-transition:all.2sease-in-out0s;-ms-transition:all.2sease-in-out0s;transition:all.2sease-in-out0s;}
.lbCon{margin-top:33px;margin-bottom:37px;position:relative;}
.lbBtn{display:block;position:absolute;top:0;width:40px;height:143px;border:1pxsolid#D7D2CA;background:url('../../../images/special/140801/ctr_prev.png')no-repeatcentercenter;}
.lbPrev{left:0}.lbNext{right:0;background-image:url('../../../images/special/140801/ctr_next.png')}
.lbBtn:hover{background-color:#ddd;}
.lbBox{width:900px;height:145px;margin-left:50px;overflow:hidden;position:relative;}
.lbList{width:1000%;}
.lbBoxul{float:left}
.lbBoxli{float:left;width:150px;height:145px;overflow:hidden;}
.lbPeo{text-align:center;line-height:18px;font-family:"寰杞闆呴粦";color:#333}
.lbPeoimg{display:block;border:1pxsolid#ddd;width:84px;height:103px;margin-left:32px;*margin-left:5px;}
.lbPeoh5{font-weight:bold;font-size:12px;padding-top:5px;*padding-top:0}
.lbPeoh6{font-size:12px;}
.lbBoxlia:hover{text-decoration:none}
.lbBoxlia:hover.lbPeo{color:#ff9600}
<!--浜虹墿-->
<divclass="lbConcomWithclearfix">
<divclass="lbBox">
<divclass="lbList">
<ul>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
</ul>
<ul>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ2绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒2澶х孩</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
<li><ahref=""target="_blank">
<divclass="lbPeoclearfix">
<imgsrc="http://img4.cache.netease.com/stock/2014/7/22/201407221627281cd88.jpg"/>
<h5>𨱒庡ぇ绾</h5>
<h6>澶у叕鎶ュ坛绀鹃暱鍏兼墽琛屾荤紪杈</h6>
</div>
</a></li>
</ul>
</div>
</div>
<ahref="javascript:;"class="lbBtnlbPrev"></a>
<ahref="javascript:;"class="lbBtnlbNext"></a>
</div>


3.椤甸溃璋幂敤锛

<script type="text/javascript" src="js/jquery-1.9.1.js"></script>

<script type="text/javascript" src="js/jquery.imgScroll.js"></script>(涓婇溃闾d釜js)

$('.lbCon.lbBox.lbList').imgScroll({
firstDiv:'.lbCon.lbBox',
scrollBox:'.lbCon.lbBox.lbList',
scrollImgBox:'.lbCon.lbBoxul',
botPrev:'.lbCon.lbPrev',
botNext:'.lbCon.lbNext',
changeType:"slide",
thumbNowClass:'on',
thumbOverEvent:true,
changeTime:5000,
ImgBoxMar:0,
flag:false
});

4.镊充簬榧犳爣婊戣繃 鏄剧ず宸﹀彸鎸夐挳,鍙浠ヨ繖涔埚啓锛堟濊矾:css榛樿ら殣钘忓乏鍙虫寜阍锛岄紶镙囨粦杩囨樉绀哄乏鍙虫寜阍锛屽垝鍑洪殣钘忥纴闇瑕佸紩鍏jquery.js锛

$(function(){
$(".wj_jdt_1").bind("onmouseover",function(){
$(".ctr_btn").show();
}).bind("onmouseout",function(){
$(".ctr_btn").hide();
})
})

澶т綋鏄杩欎箞涓镒忔濓纴镊充簬镐庝箞寤朵几鍦ㄤ綘

B. 姹俲s涓鎺掑氩紶锲剧墖钖戜笂婊氩姩浠g爜锛佷笉鏄鍗曞紶镄勬槸澶氩紶镄勶紒

锅囱句綘瑕佹粴锷ㄧ殑锲剧墖镄刬d鏄"pic1"-"picn" n>=1

function Slide()
{
for 锛坕=1;i<=n;i++) //n鏄锲剧墖鏁
{
idd="pic"+i; //鐢熸垚锲剧墖ID
toppx=parseInt(document.getElementById(idd).style.top.replace('px', '')); //銮峰彇锲剧墖top灞炴э纴骞跺幓鎺夊睘镐т箣钖庣殑px锛屽苟杞鎹㈡垚鏁村瀷鍙橀噺
toppx--; // top-1
if 锛坱oppx==???) //???鏄涓涓鏁板瓧锛屽綋锲剧墖瀹屽叏婊氩嚭鏄剧ず锣冨洿锛屽氨鎶婂浘鐗囩殑top鍙樻垚涓涓锲剧墖缇(澶氲宲ic)涓嬫柟镄勪綅缃锛屽疄鐜板惊鐜婊氩姩
{
toppx=???; //锲剧墖缇ょ殑涓嬫柟镄勪綅缃
}
document.getElementById(idd).style.top=toppx+'px'; //鏂扮殑top鍊奸佸洖锲剧墖锛屽疄鐜颁笂婊
}
}

鍙﹀栬板缑锛岃繖镙峰啓锛岄渶瑕佹妸锲剧墖镄则op灞炴у啓鍦╤tml閲岄溃锛屽啓鍦╟ss閲岄溃鏄璇讳笉鍒扮殑锛屼絾鏄杩欐牱鍐欓伩鍏崭简涓嶅悓娴忚埚櫒涓銮峰彇css涓灞炴х殑鏂规硶涓嶅悓镄勯梾棰桡纴链夊埄链夊纷銆

褰挞渶瑕佹粴锷ㄦ椂镓ц岋细s=setInterval('Slide()',50);
褰挞渶瑕佸仠姝㈡粴锷ㄦ椂镓ц岋细window.clearInterval(s);