ijquery

اسلایدشو فوکوس

screenshot

توسط این اسلایدر می توانید محصولات خود را در سایزهای مختلف و بصورت فوکوس ( محو شدن دیگر محصولات ) به نمایش بگذارید

آموزش استفاده

  1. قبل از تگ </head> کد زیر را قرار دهید : 
    <style type="text/css">
    * {margin:0; padding:0;}
    body {font-size:12px; color:#222; font-family:tahoma,Arial,Helvetica,sans-serif; background:#f0f0f0; direction:rtl;}
    .clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
    .clearfix {zoom:1;}
    ul,li {list-style:none;}
    img {border:0;}
    
    .wrapper {width:600px; margin:0 auto; padding-bottom:50px;}
    .ad {width:468px; margin:10px auto 0;}
    .ad li {padding-top:5px;}
    
    h1 {height:50px; line-height:50px; font-size:22px; font-weight:normal; font-family:"Microsoft YaHei",SimHei;}
    
    .shuoming {margin-top:20px; border:1px solid #ccc; padding-bottom:10px;}
    .shuoming dt {height:30px; line-height:30px; font-weight:bold; text-indent:10px;}
    .shuoming dd {line-height:20px; padding:5px 20px;}
    
    .wrapper {width:780px;}
    /* tmall focus */
    #focus {width:780px; height:380px; overflow:hidden; position:relative;}
    #focus ul {height:380px; position:absolute;}
    #focus ul li {float:left; width:780px; height:380px; overflow:hidden; position:relative; background:#000;}
    #focus ul li div {position:absolute; overflow:hidden;}
    #focus .btnBg {position:absolute; width:780px; height:40px; left:0; bottom:0; background:#000;}
    #focus .btn {position:absolute; width:770px; height:24px; left:0; bottom:8px; padding-left:10px;}
    #focus .btn span {display:inline-block; _display:inline; _zoom:1; width:24px; height:24px; line-height:24px; text-align:center; font-size:20px; font-family:"Microsoft YaHei",SimHei; margin-right:10px; cursor:pointer; color:#fff;}
    #focus .btn span.on {background:#000; color:#fcc;}
    </style>
    
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
    	var sWidth = $("#focus").width(); 
    	var len = $("#focus ul li").length; 
    	var index = 0;
    	var picTimer;
    
    	var btn = "<div class='btnBg'></div><div class='btn'>";
    	for(var i=0; i < len; i++) {
    		btn += "<span>" + (i+1) + "</span>";
    	}
    	btn += "</div>"
    	$("#focus").append(btn);
    	$("#focus .btnBg").css("opacity",0.5);
    
    	$("#focus .btn span").mouseenter(function() {
    		index = $("#focus .btn span").index(this);
    		showPics(index);
    	}).eq(0).trigger("mouseenter");
    
    	$("#focus ul").css("width",sWidth * (len + 1));
    
    	$("#focus ul li div").hover(function() {
    		$(this).siblings().css("opacity",0.7);
    	},function() {
    		$("#focus ul li div").css("opacity",1);
    	});
    
    	$("#focus").hover(function() {
    		clearInterval(picTimer);
    	},function() {
    		picTimer = setInterval(function() {
    			if(index == len) { 
    				showFirPic();
    				index = 0;
    			} else {
    				showPics(index);
    			}
    			index++;
    		},3000); 
    	}).trigger("mouseleave");
    
    	function showPics(index) { 
    		var nowLeft = -index*sWidth; 
    		$("#focus ul").stop(true,false).animate({"left":nowLeft},500); 
    		$("#focus .btn span").removeClass("on").eq(index).addClass("on")
    	}
    
    	function showFirPic() { 
    		$("#focus ul").append($("#focus ul li:first").clone());
    		var nowLeft = -len*sWidth;
    		$("#focus ul").stop(true,false).animate({"left":nowLeft},500,function() {
    			$("#focus ul").css("left","0");
    			$("#focus ul li:last").remove();
    		}); 
    		$("#focus .btn span").removeClass("on").eq(0).addClass("on");
    	}
    });
    
    </script>

     

  2. بعد از <body> کد زیر را قرار دهید :
    <div class="wrapper">
    	<h1>اسلایدشو فوکوس</h1>
    
    	<div id="focus">
    		<ul>
    			<li>
    				<div style="left:0; top:0; width:560px; height:380px;"><a href="#" target="_blank"><img src="img/a01.jpg" alt="" /></a></div>
    
    				<div style="right:0; top:0; width:220px; height:140px;"><a href="#" target="_blank"><img src="img/a02.jpg" alt="" /></a></div>
    				<div style="right:0; top:140px; width:220px; height:140px;"><a href="#" target="_blank"><img src="img/a03.jpg" alt="" /></a></div>
    				<div style="right:0; bottom:0; width:220px; height:100px;"><a href="#" target="_blank"><img src="img/a04.jpg" alt="" /></a></div>
    			</li>
    
    			<li>
    				<div style="left:0; top:0; width:780px; height:380px;"><a href="#" target="_blank"><img src="img/b01.jpg" alt="" /></a></div>
    			</li>
    
    			<li>
    				<div style="left:0; top:0; width:260px; height:210px;"><a href="#" target="_blank"><img src="img/c01.jpg" alt="" /></a></div>
    
    				<div style="left:260px; top:0; width:260px; height:210px;"><a href="#" target="_blank"><img src="img/c02.jpg" alt="" /></a></div>
    				<div style="left:0; top:210px; width:520px; height:170px;"><a href="#" target="_blank"><img src="img/c03.jpg" alt="" /></a></div>
    				<div style="right:0; top:0; width:260px; height:380px;"><a href="#" target="_blank"><img src="img/c04.jpg" alt="" /></a></div>
    			</li>
    
    			<li>
    				<div style="left:0; top:0; width:560px; height:380px;"><a href="#" target="_blank"><img src="img/d01.jpg" alt="" /></a></div>
    				<div style="right:0; top:0; width:220px; height:140px;"><a href="#" target="_blank"><img src="img/d02.jpg" alt="" /></a></div>
    				<div style="right:0; top:140px; width:220px; height:140px;"><a href="#" target="_blank"><img src="img/d03.jpg" alt="" /></a></div>
    				<div style="right:0; bottom:0; width:220px; height:100px;"><a href="#" target="_blank"><img src="img/d04.jpg" alt="" /></a></div>
    
    			</li>
    
    			<li>
    				<div style="left:0; top:0; width:780px; height:380px;"><a href="#" target="_blank"><img src="img/e01.jpg" alt="" /></a></div>
    			</li>
    		</ul>
    	</div>

     


پیش نمایش دانلود فایل پلاگین

دیدگاه‌ خود را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *