当前位置:编程问答 > JS >

jQuery制作的产品展示效果

问题:css+js实现的产品展示效果,使用了jQuery插件,基于1.3,更高版本也可用,原作者:浩奇。
答案:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
body,h1,h2,h3,h4,h5,h6,p,ul,ol,li,form,img,dl,dt,dd,table,th,td,blockquote,fieldset,div,strong,label,em{margin:0;padding:0;border:0;}
ul,ol,li{list-style:none;}
input,button{margin:0;font-size:12px;vertical-align:middle;}
body{font-size:12px;font-family:Arial, Helvetica, sans-serif;  margin:0 auto;}
table{border-collapse:collapse;border-spacing:0;}
p{line-height:28px}
.clearfloat{height:0;font-size:1px;clear:both;line-height:0;}
#container{  width:650px; text-align:left; margin:20px auto; }
a{color:#333;text-decoration:none;}
a:hover{color:#ef9b11; text-decoration:underline;}
.left{ width:420px; float:left;}
.left h3{ font-size:18px; padding-bottom:8px; font-weight:normal;}
.s-t{ width:100%; padding-bottom:10px;}
.s-c{ width:100%;}
.s-c h4{ font-size:14px; font-weight:normal; padding-bottom:9px;}
.s-c .pics{ width:107px; float:left;}
.s-c .p1 img{ width:100%;}
.s-c .s-detail{ width:285px; float:left; display:inline; margin-left:7px;}
.cnt{ text-indent:2em; line-height:18px;}
.right{ width:180px; float:left; BACKGROUND: #f3f3f3;}
.slide-pic { padding:10px 0px 10px 15px; HEIGHT: auto}
.slide-pic A#prev {DISPLAY: block; BACKGROUND: url(/jscss/demoimg/201010/slide.png) no-repeat; MARGIN: 0px; OVERFLOW: hidden; WIDTH: 150px; TEXT-INDENT: -9999em; HEIGHT: 14px; outline: none}
.slide-pic A#next {DISPLAY: block; BACKGROUND: url(/jscss/demoimg/201010/slide.png) no-repeat; MARGIN: 0px; OVERFLOW: hidden; WIDTH: 150px; TEXT-INDENT: -9999em; HEIGHT: 14px; outline: none}
.slide-pic A#prev {BACKGROUND-POSITION: center 0px}
.slide-pic A#next {BACKGROUND-POSITION: center -20px}
.slide-pic A#prev:hover {BACKGROUND-POSITION: center -40px}
.slide-pic A#next:hover {BACKGROUND-POSITION: center -60px}
.slide-pic A.gray#prev {BACKGROUND-POSITION: center -80px}
.slide-pic A.gray#next {BACKGROUND-POSITION: center -100px}
.slide-pic .pic-container {MARGIN: 5px 0px; OVERFLOW: hidden; WIDTH: 150px; HEIGHT: 300px}
.slide-pic UL {WIDTH: 150px}
.slide-pic UL LI {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 5px; CURSOR: pointer; PADDING-TOP: 5px
}
.slide-pic UL LI P {BORDER-RIGHT: #fff 5px solid; BORDER-TOP: #fff 5px solid; OVERFLOW: hidden; BORDER-LEFT: #fff 5px solid; WIDTH: 140px; BORDER-BOTTOM: #fff 5px solid; HEIGHT: 80px}
.slide-pic UL LI.hover P {BORDER-LEFT-COLOR: #bbbbbb; BORDER-BOTTOM-COLOR: #bbbbbb; BORDER-TOP-COLOR: #bbbbbb; BORDER-RIGHT-COLOR: #bbbbbb}
.slide-pic UL LI P IMG {WIDTH: 140px; HEIGHT: 80px}
.slide-pic UL LI.cur P {BORDER-LEFT-COLOR: #2c2c2c! important; BORDER-BOTTOM-COLOR: #2c2c2c! important; BORDER-TOP-COLOR: #2c2c2c! important; BORDER-RIGHT-COLOR: #2c2c2c! important}
.slide-pic UL LI .date {MARGIN-TOP: -20px; DISPLAY: block; Z-INDEX: 1; BACKGROUND: #fff; WIDTH: 140px; COLOR: #000; LINE-HEIGHT: 20px; POSITION: static; HEIGHT: 20px; TEXT-ALIGN: center;filter:alpha(opacity=20);-moz-opacity:0.5;-khtml-opacity: 0.5; opacity: 0.5;}
</style>
<SCRIPT src="/ajaxjs/jquery1.3.2.js" type=text/javascript></SCRIPT>
<title>jQuery制作的产品展示效果</title>
</head>
<body style="text-align:center">
	<div id="container">
		<div class="left">
			<DIV class=s-t>
				<SPAN class=date id=dailyDate><EM 
				class=ym>2010-07</EM><EM class=day>09</EM></SPAN>
			</DIV>
			<DIV class=s-c>
				<H4 id=dailyTitle>标题1</H4>
				<DIV class=s-main>
					<DIV class=pics>
						<P class="p1"><a href="#"><img alt="图片说明" id=dailyImage src="/jscss/demoimg/201010//01-big.jpg"></a></P>
						<P class=tip id=dailyImageFrom>图片说明</P>
					</DIV>
					<DIV class=s-detail>
						<DIV class=cnt id=dailyContent> 
							文字说明1
						</DIV>
					</DIV>
				</DIV>
			</div>
		</div>
		<DIV class=right>
			<DIV class=slide-pic id=slidePic>
				<A class=gray id=prev hideFocus href="javascript:;">前移</A> 
				<DIV class=pic-container>
					<UL>
					  <LI class=cur>
					  <P><IMG src="/jscss/demoimg/201010/01.jpg"><SPAN class=date>2012-12-21</SPAN></P>
					  <LI class="">
					  <P><IMG src="/jscss/demoimg/201010/02.jpg"><SPAN class=date>2012-12-21</SPAN></P>
					  <LI class="">
					  <P><IMG src="/jscss/demoimg/201010/03.jpg"><SPAN class=date>2012-12-21</SPAN></P>
					  <LI class="">
					  <P><IMG src="/jscss/demoimg/201010/04.jpg"><SPAN class=date>2012-12-21</SPAN></P>
					  <LI class="">
					  <P><IMG src="/jscss/demoimg/201010/05.jpg"><SPAN class=date>2012-12-21</SPAN></P>
					</UL>
				</DIV>
				 <A id=next hideFocus href="javascript:;">后移</A>
			</DIV>
		  
			<SCRIPT type=text/javascript>
			var areaDailyList = [{"content":"文字说明1<br>","id":29,"title":"标题1","image":"/jscss/demoimg/201010/01-big.jpg","date":"2010-07-09","imageFrom":"图片说明1"},{"content":"文字说明2","id":28,"title":"标题2","image":"/jscss/demoimg/201010/02-big.jpg","date":"2010-07-08","imageFrom":"图片说明2"},{"content":"文字说明3","id":27,"title":"标题3","image":"/jscss/demoimg/201010/03-big.jpg","date":"2010-07-07","imageFrom":"图片说明3"},{"content":"文字说明4","id":20,"title":"标题4","image":"/jscss/demoimg/201010/04-big.jpg","date":"2010-07-06","imageFrom":"图片说明4"},{"content":"文字说明5","id":24,"title":"标题5","image":"/jscss/demoimg/201010/05-big.jpg","date":"2010-07-05","imageFrom":"图片说明5"}];
			jQuery(function(){
			if (!$('#slidePic')[0]) 
			return;
			var i = 0, p = $('#slidePic ul'), pList = $('#slidePic ul li'), len = pList.length;
			var elePrev = $('#prev'), eleNext = $('#next');
			//var firstClick = false;
			var w = 100, num = 3;
			p.css('width',w*len);
			if (len <= num) 
			eleNext.addClass('gray');
			function prev(){
			if (elePrev.hasClass('gray')) {
			//alert('已经是第一张了');
			return;
			}
			p.animate({
			marginTop:-(--i) * w
			},500);
			if (i < len - num) {
			eleNext.removeClass('gray');
			}
			if (i == 0) {
			elePrev.addClass('gray');
			}
			}
			function next(){
			if (eleNext.hasClass('gray')) {
			//alert('已经是最后一张了');
			return;
			}
			//p.css('margin-left',-(++i) * w);
			p.animate({
			marginTop:-(++i) * w
			},500);
			if (i != 0) {
			elePrev.removeClass('gray');
			}
			if (i == len - num) {
			eleNext.addClass('gray');
			}
			}
			elePrev.bind('click',prev);
			eleNext.bind('click',next);
			pList.each(function(n,v){
			$(this).click(function(){
			if(n-i == 2){
			next();
			}
			if(n-i == 0){
			prev()
			}
			$('#slidePic ul li.cur').removeClass('cur');
			$(this).addClass('cur');
			show(n);
			}).mouseover(function(){
			$(this).addClass('hover');
			}).mouseout(function(){
			$(this).removeClass('hover');
			})
			});
			function show(i){
			var ad = areaDailyList[i];
			var t = ad.date.split('-');
			$('#dailyTitle').html(ad.title);
			$('#dailyImage').attr('src',ad.image);
			$('#dailyImageFrom').html('' + ad.imageFrom + '');
			$('#dailyContent').html(ad.content);
			$('#dailyDate').html('<em class="ym">' + t[0] + '.' + t[1] + '</em><em class="day">' + t[2] + '</em>');
			var shareRRUrl = encodeURIComponent('http://www.nuomi.com/share365/'+ad.id);
			var shareUrl = encodeURIComponent('http://www.baidu.com');
			var shareTitle = encodeURIComponent(ad.title + 'http://www.zzzyk.com');
			var shareContent = encodeURIComponent(ad.content.substring(0,100)+'...');
			
			}
			});
			</SCRIPT>
		</DIV>
	</div>
</body>
</html>

上一个:CSS+JavaScript仿FLASH的图片轮换效果
下一个:同一页面调用并显示多个图片幻灯切换效果

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,