网站首页js幻灯片代码

JS图片幻灯片,网站首页专用的图片特效代码,旅游网站用着最合适了,支持图片说明,每一幅图片都可以加标题和简短的文字介绍,右下角有图片切换控制按钮,示例中仅有5张图片,不过在实际应用中,你可以添加更多的图片。 <!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> <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; <!--for(var i=1;i<oli.length;i++){rqbd.innerHTML+="<li>"+i+"</li>";}--> 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].οnclick=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.οnmοuseοver=function(){clearInterval(extime);clearInterval(wwww);} o.οnmοuseοut=function(){extime=setInterval(bc,15);wwww=setInterval(uu,8000);} } </script> </head> <body> <!-------- content start ---------> <div id="content"> <!-- ===================== header end ===================== --> <!--------main begin---------> <div id="main"> <!-----------图片切换 begin-----------> <div class="sub_box"> <div id="p-select" class="sub_nav"> <div class="sub_more"><a href="/" οnfοcus="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="http://www.codefans.net" title="" target="_blank"><img src="http://www.codefans.net/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="http://www.codefans.net/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="http://www.codefans.net/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="http://www.codefans.net/jscss/demoimg/wall4.jpg" alt="2011西安世园会攻略"></a></dt> <dd> <h2><a href="http://www.codefans.net/" target="_blank">2011西安世园会攻略</a></h2> <tt><a href="#" target="_blank">提供最全面西安世园会资讯、西安世园会参观指南、西安世园会旅游…</a></tt> </dd> </dl> <dl class=""> <dt><a href="http://www.codefans.net/" title="" target="_blank"><img src="http://www.codefans.net/jscss/demoimg/wall5.jpg" alt="五月乐享懒人天堂塞班岛"></a></dt> <dd> <h2><a href="http://www.codefans.net/jscss/" target="_blank">五月乐享懒人天堂塞班岛</a></h2> <tt><a href="#" target="_blank">塞班岛是北马里亚纳群岛的首府,由于近邻赤道,塞班岛一年四季如…</a></tt> </dd> </dl> </div> </div> </div> <script type="text/javascript">movec();</script> <!-----------图片切换 end-----------> </div> <!--------main end---------> </div> </body> </html>

转载于:https://www.cnblogs.com/zdcaolei/archive/2011/07/29/2122930.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值