Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2313967
  • 博文数量: 252
  • 博客积分: 5472
  • 博客等级: 大校
  • 技术积分: 3107
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-17 18:39
文章分类

全部博文(252)

文章存档

2012年(96)

2011年(156)

分类: 系统运维

2011-11-16 16:23:17

  • JS图片幻灯片,网站首页专用的图片特效代码,旅游网站用着最合适了,支持图片说明,每一幅图片都可以加标题和简短的文字介绍,右下角有图片切换控制按钮,示例中仅有5张图片,不过在实际应用中,你可以添加更多的图片。
    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    2. <html xmlns="">
    3. <head>
    4. <title>JS图片幻灯片</title>
    5. <style>
    6. *{margin:0;padding:0;}
    7. ul,li,ol{ list-style:none;}
    8. img,a img{ border:none;}
    9. table{ border-collapse:collapse; border-spacing:0;}
    10. em,i,u{ font-style:normal;}
    11. a{ text-decoration:none;color:#434343;}
    12. a:hover{ text-decoration:underline; color:#ff4000;}
    13. body{font-size:12px; font-family:"宋体";color:#434343;}
    14. .clear{clear:both; font-size:0; overflow:hidden; height:0;}
    15. .blank10{clear:both; font-size:0; overflow:hidden; height:10px;}
    16. .blank{clear:both; font-size:0; overflow:hidden; height:10px; background:#FFF;}
    17. /*********content css定义***********/
    18. #content{width:960px;margin:0 auto;}
    19. h1,h2,h3{ font-family:"微软雅黑";color:#00659b;}
    20. h1,h2,h3,h4,h5,h6{ font-weight:bold;}
    21. #footer{padding-bottom:0;margin:0px auto 0;}
    22. /*********main css定义***********/
    23. .mb15 {margin-bottom: 0px;}
    24. #main{width:960px; margin:6px auto 10px; overflow:hidden;}
    25. /*********图片切换 css定义***********/
    26. .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;}
    27. .sub_box img{border:none; width:663px; height:310px;}
    28. #bd1lfimg{position:relative; width:663px; height:310px; overflow:hidden;}
    29. #bd1lfimg div{width:100000px; margin-left:-4px;}
    30. #bd1lfimg dl{width:663px; height:310px; position:relative; overflow:hidden; float:left;}
    31. #bd1lfimg dt{width:663px; height:310px; position:absolute; left:0px; top:0px;}
    32. #bd1lfimg dd{width:623px; height:80px; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; position:absolute; left:0px; bottom:0px; padding:0 20px;}
    33. #bd1lfimg dd h2{height:25px; padding:8px 0 4px 0; line-height:25px; overflow:hidden;}
    34. #bd1lfimg dd h2 a{font-size:14px; font-weight:bold; color:#ffffff;}
    35. #bd1lfimg dd a{color:#ffffff; text-decoration:none;}
    36. #bd1lfimg dd a:hover{text-decoration:none; color:#cccccc;}
    37. #bd1lfimg dd tt{color:#dddddd; line-height:1.2em;}
    38. #bd1lfimg dd tt a:hover{text-decoration:underline;}
    39. .sub_nav{width:663px; height:25px; bottom:0px; position:absolute; color:#999999; z-index:200;}
    40. .sub_no{height:25px; float:right;}
    41. .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;}
    42. .sub_no li.show{background:#ffffff; color:#000000;}
    43. .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;}
    44. .sub_more a{color:#999999;}
    45. .sub_more a:hover{color:#cccccc; text-decoration:none;}
    46. </style>
    47. <script type="text/javascript">
    48. //选择器
    49. function $a(id,tag){var re=(id&&typeof id!="string")?id:document.getElementById(id);if(!tag){return re;}else{return re.getElementsByTagName(tag);}}

    50. //焦点滚动图 点击移动
    51. function movec()
    52. {
    53.     var o=$a("bd1lfimg","");
    54.     var oli=$a("bd1lfimg","dl");
    55.     var oliw=oli[0].offsetWidth; //每次移动的宽度    
    56.     var ow=o.offsetWidth-2;
    57.     var dnow=0; //当前位置    
    58.     var olf=oliw-(ow-oliw+10)/2;
    59.         o["scrollLeft"]=olf+(dnow*oliw);
    60.     var rqbd=$a("bd1lfsj","ul")[0];
    61.     var extime;

    62.     
    63.     var rq=$a("bd1lfsj","li");
    64.     for(var i=0;i<rq.length;i++){reg(i);};
    65.     oli[dnow].className=rq[dnow].className="show";
    66.     var wwww=setInterval(uu,2000);

    67.     function reg(i){rq[i].onclick=function(){oli[dnow].className=rq[dnow].className="";dnow=i;oli[dnow].className=rq[dnow].className="show";mv();}}
    68.     function mv(){clearInterval(extime);clearInterval(wwww);extime=setInterval(bc,15);wwww=setInterval(uu,8000);}
    69.     function bc()
    70.     {
    71.         var ns=((dnow*oliw+olf)-o["scrollLeft"]);
    72.         var v=ns>0?Math.ceil(ns/10):Math.floor(ns/10);
    73.         o["scrollLeft"]+=v;if(v==0){clearInterval(extime);oli[dnow].className=rq[dnow].className="show";v=null;}
    74.     }
    75.     function uu()
    76.     {
    77.         if(dnow<oli.length-2)
    78.         {
    79.             oli[dnow].className=rq[dnow].className="";
    80.             dnow++;
    81.             oli[dnow].className=rq[dnow].className="show";
    82.         }
    83.         else{oli[dnow].className=rq[dnow].className="";dnow=0;oli[dnow].className=rq[dnow].className="show";}
    84.         mv();
    85.     }
    86.     o.onmouseover=function(){clearInterval(extime);clearInterval(wwww);}
    87.     o.onmouseout=function(){extime=setInterval(bc,15);wwww=setInterval(uu,8000);}
    88. }
    89. </script>    
    90.     
    91. </head>

    92. <body>

    93.     
    94.     <div id="content">


    95.         
    96.     

    97.     
    98.     <div id="main">

    99.         
    100.         <div class="sub_box">
    101.             <div id="p-select" class="sub_nav">
    102.                 <div class="sub_more"><a href="/" onfocus="this.blur()" title="查看更多目的地旅游指南" style="font-family: Tahoma; font-size: 12px;" target="_blank">更多>></a></div>
    103.                 <div class="sub_no" id="bd1lfsj">
    104.                     <ul>
    105.                         <li class="show">1</li><li class="">2</li><li class="">3</li><li class="">4</li><li class="">5</li>
    106.                     </ul>
    107.                 </div>
    108.             </div>
    109.             <div id="bd1lfimg">
    110.                 <div>
    111.                     <dl class="show"></dl>
    112.                                         <dl class="">
    113.                         <dt><a href="" title="" target="_blank"><img src="/jscss/demoimg/wall1.jpg" alt="2011城市主题公园亲子游"></a></dt>
    114.                         <dd>
    115.                             <h2><a href="#" target="_blank">2011城市主题公园亲子游</a></h2>
    116.                             <tt><a href="#" target="_blank">又是春游踏青的季节,各大主题乐园都为大朋友、小朋友们准备了丰…</a></tt>
    117.                         </dd>
    118.                     </dl>
    119.                                         <dl class="">
    120.                         <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall2.jpg" alt="潜入城市周边清幽之地"></a></dt>
    121.                         <dd>
    122.                             <h2><a href="#" target="_blank">潜入城市周边清幽之地</a></h2>
    123.                             <tt><a href="#" target="_blank">北京、上海、广州、成都周边,总有些人少清幽的地方,等着你去探…</a></tt>
    124.                         </dd>
    125.                     </dl>
    126.                                         <dl class="">
    127.                         <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall3.jpg" alt="盘点中国最美雪山"></a></dt>
    128.                         <dd>
    129.                             <h2><a href="#" target="_blank">盘点中国最美雪山</a></h2>
    130.                             <tt><a href="#" target="_blank">盘点中国最美雪山,从云南的梅里到西藏的珠穆朗玛,带你领略中国…</a></tt>
    131.                         </dd>
    132.                     </dl>
    133.                                         <dl class="">
    134.                         <dt><a href="#" title="" target="_blank"><img src="/jscss/demoimg/wall4.jpg" alt="2011西安世园会攻略"></a></dt>
    135.                         <dd>
    136.                             <h2><a href="/" target="_blank">2011西安世园会攻略</a></h2>
    137.                             <tt><a href="#" target="_blank">提供最全面西安世园会资讯、西安世园会参观指南、西安世园会旅游…</a></tt>
    138.                         </dd>
    139.                     </dl>
    140.                                         <dl class="">
    141.                         <dt><a href="/" title="" target="_blank"><img src="/jscss/demoimg/wall5.jpg" alt="五月乐享懒人天堂塞班岛"></a></dt>
    142.                         <dd>
    143.                             <h2><a href="/jscss/" target="_blank">五月乐享懒人天堂塞班岛</a></h2>
    144.                             <tt><a href="#" target="_blank">塞班岛是北马里亚纳群岛的首府,由于近邻赤道,塞班岛一年四季如…</a></tt>
    145.                         </dd>
    146.                     </dl>
    147.                                     </div>
    148.             </div>
    149.         </div>
    150.         <script type="text/javascript">movec();</script>
    151.         
    152.     </div>
    153.     
    154. </div>
    155. </body>
    156. </html>
  • 阅读(4874) | 评论(2) | 转发(1) |
    给主人留下些什么吧!~~

    xueliangfei2011-11-21 15:26:29

    十七岁的回忆: ( ^_^ )不错嘛,试一下~.....
    额。。不是原创  都是学习别人的。。

    十七岁的回忆2011-11-19 20:43:32

    ( ^_^ )不错嘛,试一下~