JS图片幻灯片,网站首页专用的图片特效代码,旅游网站用着最合适了,支持图片说明,每一幅图片都可以加标题和简短的文字介绍,右下角有图片切换控制按钮,示例中仅有5张图片,不过在实际应用中,你可以添加更多的图片。
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
- <html xmlns="">
- <head>
- <title>JS图片幻灯片</title>
- <style>
- *{margin:0;padding:0;}
- ul,li,ol{ list-style:none;}
- img,a img{ border:none;}
- table{ border-collapse:collapse; border-spacing:0;}
- em,i,u{ font-style:normal;}
- a{ text-decoration:none;color:#434343;}
- a:hover{ text-decoration:underline; color:#ff4000;}
- body{font-size:12px; font-family:"宋体";color:#434343;}
- .clear{clear:both; font-size:0; overflow:hidden; height:0;}
- .blank10{clear:both; font-size:0; overflow:hidden; height:10px;}
- .blank{clear:both; font-size:0; overflow:hidden; height:10px; background:#FFF;}
- /*********content css定义***********/
- #content{width:960px;margin:0 auto;}
- h1,h2,h3{ font-family:"微软雅黑";color:#00659b;}
- h1,h2,h3,h4,h5,h6{ font-weight:bold;}
- #footer{padding-bottom:0;margin:0px auto 0;}
- /*********main css定义***********/
- .mb15 {margin-bottom: 0px;}
- #main{width:960px; margin:6px auto 10px; overflow:hidden;}
- /*********图片切换 css定义***********/
- .sub_box{width:663px; height:310px; float:left; position:relative; overflow:hidden; border:1px solid #cccccc; background:url() center center no-repeat; *background:url() 220px 120px no-repeat;}
- .sub_box img{border:none; width:663px; height:310px;}
- #bd1lfimg{position:relative; width:663px; height:310px; overflow:hidden;}
- #bd1lfimg div{width:100000px; margin-left:-4px;}
- #bd1lfimg dl{width:663px; height:310px; position:relative; overflow:hidden; float:left;}
- #bd1lfimg dt{width:663px; height:310px; position:absolute; left:0px; top:0px;}
- #bd1lfimg dd{width:623px; height:80px; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; position:absolute; left:0px; bottom:0px; padding:0 20px;}
- #bd1lfimg dd h2{height:25px; padding:8px 0 4px 0; line-height:25px; overflow:hidden;}
- #bd1lfimg dd h2 a{font-size:14px; font-weight:bold; color:#ffffff;}
- #bd1lfimg dd a{color:#ffffff; text-decoration:none;}
- #bd1lfimg dd a:hover{text-decoration:none; color:#cccccc;}
- #bd1lfimg dd tt{color:#dddddd; line-height:1.2em;}
- #bd1lfimg dd tt a:hover{text-decoration:underline;}
- .sub_nav{width:663px; height:25px; bottom:0px; position:absolute; color:#999999; z-index:200;}
- .sub_no{height:25px; float:right;}
- .sub_no li{display:block; width:25px; height:25px; float:left; overflow:hidden; line-height:25px; vertical-align:middle; text-align:center; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; font-family:Arial; font-size:11px; color:#999999; cursor:pointer;}
- .sub_no li.show{background:#ffffff; color:#000000;}
- .sub_more{float:right; width:50px; height:25px; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; color:#999999; text-align:center; line-height:25px;}
- .sub_more a{color:#999999;}
- .sub_more a:hover{color:#cccccc; text-decoration:none;}
- </style>
- <script type="text/javascript">
- //选择器
- function $a(id,tag){var re=(id&&typeof id!="string")?id:document.getElementById(id);if(!tag){return re;}else{return re.getElementsByTagName(tag);}}
- //焦点滚动图 点击移动
- function movec()
- {
- var o=$a("bd1lfimg","");
- var oli=$a("bd1lfimg","dl");
- var oliw=oli[0].offsetWidth; //每次移动的宽度
- var ow=o.offsetWidth-2;
- var dnow=0; //当前位置
- var olf=oliw-(ow-oliw+10)/2;
- o["scrollLeft"]=olf+(dnow*oliw);
- var rqbd=$a("bd1lfsj","ul")[0];
- var extime;
-
- var rq=$a("bd1lfsj","li");
- for(var i=0;i<rq.length;i++){reg(i);};
- oli[dnow].className=rq[dnow].className="show";
- var wwww=setInterval(uu,2000);
- function reg(i){rq[i].onclick=function(){oli[dnow].className=rq[dnow].className="";dnow=i;oli[dnow].className=rq[dnow].className="show";mv();}}
- function mv(){clearInterval(extime);clearInterval(wwww);extime=setInterval(bc,15);wwww=setInterval(uu,8000);}
- function bc()
- {
- var ns=((dnow*oliw+olf)-o["scrollLeft"]);
- var v=ns>0?Math.ceil(ns/10):Math.floor(ns/10);
- o["scrollLeft"]+=v;if(v==0){clearInterval(extime);oli[dnow].className=rq[dnow].className="show";v=null;}
- }
- function uu()
- {
- if(dnow<oli.length-2)
- {
- oli[dnow].className=rq[dnow].className="";
- dnow++;
- oli[dnow].className=rq[dnow].className="show";
- }
- else{oli[dnow].className=rq[dnow].className="";dnow=0;oli[dnow].className=rq[dnow].className="show";}
- mv();
- }
- o.onmouseover=function(){clearInterval(extime);clearInterval(wwww);}
- o.onmouseout=function(){extime=setInterval(bc,15);wwww=setInterval(uu,8000);}
- }
- </script>
-
- </head>
- <body>
-
- <div id="content">
-
-
-
- <div id="main">
-
- <div class="sub_box">
- <div id="p-select" class="sub_nav">
- <div class="sub_more"><a href="/" onfocus="this.blur()" title="查看更多目的地旅游指南" style="font-family: Tahoma; font-size: 12px;" target="_blank">更多>></a></div>
- <div class="sub_no" id="bd1lfsj">
- <ul>
- <li class="show">1</li><li class="">2</li><li class="">3</li><li class="">4</li><li class="">5</li>
- </ul>
- </div>
- </div>
- <div id="bd1lfimg">
- <div>
- <dl class="show"></dl>
- <dl class="">
- <dt><a href="" title="" target="_blank"><img src="/jscss/demoimg/wall1.jpg" alt="2011城市主题公园亲子游"></a></dt>
- <dd>
- <h2><a href="#" target="_blank">2011城市主题公园亲子游</a></h2>
- <tt><a href="#" target="_blank">又是春游踏青的季节,各大主题乐园都为大朋友、小朋友们准备了丰…</a></tt>
- </dd>
- </dl>
- <dl class="">
- <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall2.jpg" alt="潜入城市周边清幽之地"></a></dt>
- <dd>
- <h2><a href="#" target="_blank">潜入城市周边清幽之地</a></h2>
- <tt><a href="#" target="_blank">北京、上海、广州、成都周边,总有些人少清幽的地方,等着你去探…</a></tt>
- </dd>
- </dl>
- <dl class="">
- <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall3.jpg" alt="盘点中国最美雪山"></a></dt>
- <dd>
- <h2><a href="#" target="_blank">盘点中国最美雪山</a></h2>
- <tt><a href="#" target="_blank">盘点中国最美雪山,从云南的梅里到西藏的珠穆朗玛,带你领略中国…</a></tt>
- </dd>
- </dl>
- <dl class="">
- <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall4.jpg" alt="2011西安世园会攻略"></a></dt>
- <dd>
- <h2><a href="/" target="_blank">2011西安世园会攻略</a></h2>
- <tt><a href="#" target="_blank">提供最全面西安世园会资讯、西安世园会参观指南、西安世园会旅游…</a></tt>
- </dd>
- </dl>
- <dl class="">
- <dt><a href="/" title="" target="_blank"><img src="/jscss/demoimg/wall5.jpg" alt="五月乐享懒人天堂塞班岛"></a></dt>
- <dd>
- <h2><a href="/jscss/" target="_blank">五月乐享懒人天堂塞班岛</a></h2>
- <tt><a href="#" target="_blank">塞班岛是北马里亚纳群岛的首府,由于近邻赤道,塞班岛一年四季如…</a></tt>
- </dd>
- </dl>
- </div>
- </div>
- </div>
- <script type="text/javascript">movec();</script>
-
- </div>
-
- </div>
- </body>
- </html>
阅读(4924) | 评论(2) | 转发(1) |