jquery仿搜狗壁纸官网带图标控制的banner宽屏图片切换代码



108 429 144



特效描述: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

加群请备注:从官网了解到