jquery仿搜狗壁紙官網帶圖標控制的banner寬屏圖片切換代碼



113 448 150



特效描述:jquery 帶圖標控制 banner寬屏圖片切換,騰訊團購切換特效,騰訊團購切換特效。

代碼結構

1. 引入CSS

<link href="css/wallpaper.css" type="text/css" rel="stylesheet">

2. 引入JS

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

3. HTML代碼

<div class="bannertop">
	<div class="bannerwin" id="bannerwin">
		<div class="bannerwapper">
			<div class="bannercontent" id="forwin">
				<a class="windows_ico" id="btnplay0"></a>
				<a class="ios_ico" id="btnplay1"></a>
				<a class="android_ico" id="btnplay2"></a>
				<div class="forwait"></div>
				<span class="arrow"></span>
				<div class="forwin textdisp"></div>
				<a href="http://www.dijiuzhanzhang.com" class="forwin downloadpc"></a>
				<span class="changeTime">
					<span class="times"></span>
					<span class="downtri"></span>
				</span>
				<div class="screenpc forwin"></div>
			</div>
		</div>
	</div>
	<div class="bannerandr" id="bannerandr">
		<div class="bannerwapper">
			<div class="bannercontent" id="forandr">
				<a class="windows_ico" id="btnplay0"></a>
				<a class="ios_ico" id="btnplay1"></a>
				<a class="android_ico" id="btnplay2"></a>
				<span class="arrow"></span>
				<div class="andrtext forandroid"></div>
				<a href="http://www.dijiuzhanzhang.com" class="downandroid forandroid"></a>
				<div class="androidDis forandroid"></div>
				<div class="androidcode forandroid"></div>
				<div class="scancode forandroid"></div>
				<a href="http://www.dijiuzhanzhang.com" class="wandou forandroid" name="搜狗壁紙android版" title="通過豌豆莢下載"><img alt="豌豆莢一鍵安裝" src="images/wandou.png"/></a>
			</div>
		</div>
	</div>
	<div class="bannerios">
		<div class="bannerwapper">
			<div class="bannercontent" id="banner0">
				<div class="forios iospart"></div>
				<a class="windows_ico" id="btnplay0"></a><a class="ios_ico" id="btnplay1"></a><a class="android_ico" id="btnplay2"></a>
				<div class="forwait"></div>
				<span class="arrow"></span>
				<div class="iphonepart">
					<div class="partwrapper">
						<div class="downloadup ioshide hoverstop"></div>
						<a class="downiphone iospart hoverstop" id="downiphone"></a>
						<div class="downloaddown ioshide hoverstop">
							<div class="innerIphone hoverstop">
								<a class="dirdown hoverstop" href="http://www.dijiuzhanzhang.com" title="直接下載,需越獄"></a>
								<a class="istoredown hoverstop" href="http://www.dijiuzhanzhang.com" title="官方下載"></a>
							</div>
						</div>
					</div>
				</div>
				<div class="ioswpart">
					<div class="partwrapper">
						<div class="ipadup ioshide hoverstop"></div>
						<a class="downipad iospart hoverstop" id="downipad"></a>
						<div class="ipaddown ioshide hoverstop">
							<div class="innerIpad hoverstop"> 
								<a class="paddirdown  hoverstop" href="http://www.dijiuzhanzhang.com" title="直接下載"></a>
								<a class="istorepaddown hoverstop" target="_blank" href="https://itunes.apple.com/cn/app/id641418313" title="官方下載"></a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	/* 按鈕觸碰效果 */
	function showSlideToggle(){
		if($("#downiphone").is(":animated")){
			return;
		}
		showTog(".downloadup",100);
		showTog(".downloaddown",200);
		changeIpPos();                                           
	}
	function changeIpPos(){
		$("#downiphone").toggleClass("active");   
		if($("#downiphone").hasClass("active")){
			$("#downiphone").css("backgroundPosition","-29px -152px");
		}else{
			$("#downiphone").css("backgroundPosition","-29px -30px");
		}
	}
	function showSlide(){
		if($("#downiphone").is(":animated")){
			return;
		}
		showDown(".downloadup",100);
		showDown(".downloaddown",200);
		$("#downiphone").addClass("active");
		$("#downiphone").css("backgroundPosition","-29px -152px");
	}
	function showTog(ele,speed){
		$(ele).slideToggle(speed);
	}
	function showDown(ele,speed){
		$(ele).slideDown(speed);
	}
	function showIpad(){
		if($("#downipad").is(":animated")){
			return;
		}
		showDown(".ipadup",100);
		showDown(".ipaddown",200);
		$("#downipad").addClass("active");
		$("#downipad").css("backgroundPosition","-205px -296px");
	}
	function showIpadToggle(){
		if($("#downiphone").is(":animated")){
			return;
		}
		showTog(".ipadup",100);
		showTog(".ipaddown",200);
		chgrIpadPos(true);
	}
	function chgrIpadPos(flag){
		$("#downipad").toggleClass("active");   
		if(!$("#downipad").hasClass("active")){
			$("#downipad").css("backgroundPosition","-29px -296px");
		}else{
			$("#downipad").css("backgroundPosition","-205px -296px");
		}
	}
	function hideIphone(){
		$(".downloadup").slideUp(200);
		$(".downloaddown").slideUp(200);
		$("#downiphone").removeClass("active");
		$("#downiphone").css("backgroundPosition","-29px -30px");
	}
	function hideIpad(){
		$(".ipadup").slideUp(200);
		$(".ipaddown").slideUp(200);
		$("#downipad").removeClass("active");
		$("#downipad").css("backgroundPosition","-29px -296px");
	}
	$("#downiphone").hover(function(){
		showSlide();
	});
	$("#downipad").hover(function(){
		showIpad();
	});
	$(".iphonepart").mouseleave(function(){
		hideIphone();
	});
	$(".ioswpart").mouseleave(function(){
		hideIpad();
	});
	/* 圖片輪播效果,暫時注釋掉輪播效果,只在點擊時切換 */
	var timer = null;
	var interval = 8000;
	var stayTime = 7500;
	var len = 2;
	var index = 0;
	var timeoutRoll = null;
	$(".android_ico").click(function(){
		playAndroid();
	});
	$(".windows_ico").click(function(){
		playWindows();
	});
	$(".ios_ico").click(function(){
		playIos();
	});
	var tag="";
	if(tag == "ios"){
		playIos();
	}else if(tag=="android"){
		playAndroid();
	}else{
		playWindows();
	}
	function clearTimer(){
		clearInterval(timer);
		clearTimeout(timeoutRoll);
	}
	function setNewInterval(){
		timer = setInterval(function(){
			index++;
			if(index == len){
				index = 0;
			}
			play(index);
		},interval);
	}
	/* windows Banner背景圖效果 */
	setCurBg();
	$(".changeTime").click(function(){
		clearTimer();
		var cur = getCurBg();
		cur++;
		if(cur > 12){
		   cur = 1;
		}
		setBg(cur);
	});
	function getCurBg(){
		var bgstr = $(".bannerwin").css("backgroundImage");
		var preg = /\/(\d+)\.jpg/i;
		var res = bgstr.match(preg);
		if(res != false){
			return res[1];
		}
		/* 默認顯示第一個時間點 */
		return 1;    
	}
	function getTimePos(i){
		if(i<=0 || i>13){
			i = 1;
		}
		var pos = ['-10px -10px','-67px -10px','-124px -10px','-181px -10px','-10px -108px','-67px -108px','-124px -108px','-181px -108px','-10px -206px','-67px -206px','-124px -206px','-181px -206px'];
		return pos[i-1];
	}
	/* 24小時轉為時辰 */
	function getCurHour(){
		var hour = new Date().getHours();
		if(hour<0||hour>23){
			hour = 0;
		}
		var shour;
		if(hour==0 || hour ==23){
			shour = 1;
		}else{
			shour = Math.floor((hour+1)/2)+1;
		}
		return shour;
	}
	function setCurBg(){
		var cur = getCurHour();
		setBg(cur);
	}
	function setBg(cur){
		if(cur<1 || cur>12){
			cur = 1;
		}
		var bgscreen = getTimePos(cur);
		$(".bannerwin").css("backgroundImage","url(images/"+cur+".jpg)");
		$(".times").css("background-position",bgscreen);
		$(".screenpc").css("backgroundImage","url(images/bg"+'6'+".png)");
	}
	function play(index){
		if(index == 0){
			playIos();
			return;
		}
		playWindows();
	}
	function init(){
		$(".iospart").stop().css({"left":"2000px"});
		$(".forwin").stop().css("left","2000px");
		$(".forandroid").stop().css("left","2000px");
		$(".downloadup, .ipadup").stop().css({"height":"55px","display":"none"});
		$(".downloaddown, .ipaddown").stop().css({"height":"94px","display":"none"});
		$(".bannerios").css("left","100%");
		$(".bannerwin").css("left","100%");
		$(".bannerandr").css("left","100%");
		$(".ios_ico").removeClass("ios_active");
		$(".windows_ico").removeClass("windows_active");
		$(".android_ico").removeClass("android_active");
		$("#downipad").css("backgroundPosition","-29px -296px");
		$("#downiphone").css("backgroundPosition","-29px -30px");
		$(".ioshide").stop().fadeOut(10);
	}
	function initIos(){
		init();
		$(".arrow").css("left","498px");
		$(".bannerios").css("left","0");
		$(".ios_ico").addClass("ios_active");
	}
	function playIos(){
		initIos();
		$("#downiphone").animate({"left":"0"},400,function(){
			$("#downipad").animate({"left":"0"},400,function(){
				$(".forios").show().css({"left":"482px"}).css({"opacity":1}).hide().fadeIn(1200); 
			});    
		});
	}
	function initWindows(){
		init();
		$(".windows_ico").addClass("windows_active");
		$(".arrow").css("left","439px");
		$(".bannerwin").css("left","0");
	}
	function playWindows(){
		initWindows();
		/* windows進入動畫 */
		$(".screenpc").animate({"left":"52px"},400,function(){
			$(".downloadpc").animate({"left":"569px"},500);    
			$(".textdisp").animate({"left":"569px"},500);    
		});
	}
	function initAndroid(){
		init();
		$(".bannerandr").css("left","0");
		$(".android_ico").addClass("android_active");
		$(".arrow").css("left","557px");
	}
	function playAndroid(){
		initAndroid();
		$(".downandroid").animate({"left":"100px"},400);
		$(".wandou").animate({"left":"99px"},400);
		$(".androidcode").animate({"left":"0"},400);
		$(".scancode").animate({"left":"104px"},400);
		$(".andrtext").animate({"left":"0"},400,function(){
			$(".androidDis").animate({"left":"493px"},400);
		});
	}
	/* windos banner圖片緩存 */
	for(var i = 1;i<=12;i++){
	/*
	 * 1.如果new 在循環外,更改src會取消上次請求
	 * 2.同一個image對象更改兩次src,第二次會取消第一次的請求。
	 * 3.由于每次生成image對象。請求地址后刪除,釋放資源 
	 * 4.請求的資源較大,放在頁面加載完畢后,且置于腳本最后
	 * 5.申請的image臨時對象請求之前不能unset。否則會取消src的圖片請求
	 */
	var image = new Image;
	var imagebg = new Image;
		image.src = "/images/"+i+".jpg";    
		imagebg.src = "/images/bg"+i+".png";
	}
});
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 滑動 滑塊 滑動門 觸屏滑動 滑動插件 滑塊插件 滑動選項卡 滑動切換 滾動切換 滾動條切換 flash焦點圖 flash幻燈片 flashbanner flash圖片輪播 滑動手風琴 選項卡切換 選項卡 切換 tab切換 頁面切換 選項卡插件 切換插件 全屏焦點圖 漸隱切換 全屏切換 淡出淡進 淡出 淡進 切換按鈕 寬屏全屏 寬屏 全屏 頁面全屏 頁面寬屏 表單 表單美化 表單插件 表單美化插件 焦點圖 幻燈片 輪播圖 bar焦點圖 圖片淡出淡進 圖片淡出 圖片淡進 圖片全屏 圖片滑動 圖片滑塊 圖片切換 圖片選項卡 圖標選項卡 純圖片輪播 圖片輪播 按鈕控制
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

湖北30选5开奖结果走势图表