首页 > 代码库 > JS——网页图片轮播特效

JS——网页图片轮播特效

焦点图轮播

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml"><head>
 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 4 <meta http-equiv="Content-Language" content="zh-CN">
 5 <meta name="Keywords" content="SuperSlide,jQuery焦点图/幻灯片">
 6 <meta name="Description" content="SuperSlide 致力于解决网站大部分特效展示问题,使网站代码规范整洁,方便维护更新。网站上常用的“焦点图/幻灯片”、“Tab标签切换”、“图片滚动”、“无缝滚动”等等只需要一个SuperSlide即可解决!还可以多个SuperSlide组合创造更多效果">
 7 <title>SuperSlide - 焦点图/幻灯片</title>
 8 <script type="text/javascript" src="http://www.mamicode.com/jquery1.42.min.js"></script><script type="text/javascript" src="http://www.mamicode.com/jquery.SuperSlide.2.1.js"></script>
 9 </head>
10 
11 <body>
12 
13 
14 
15         <style type="text/css">
16         /* css 重置 */
17         *{margin:0; padding:0; list-style:none; }
18         body{ background:#fff; font:normal 12px/22px 宋体;  }
19         img{ border:0;  }
20         a{ text-decoration:none; color:#333;  }
21 
22         /* 本例子css */
23         .slideBox{ width:450px; height:230px; overflow:hidden; position:relative; border:1px solid #ddd;  }
24         .slideBox .hd{ height:15px; overflow:hidden; position:absolute; right:5px; bottom:5px; z-index:1; }
25         .slideBox .hd ul{ overflow:hidden; zoom:1; float:left;  }
26         .slideBox .hd ul li{ float:left; margin-right:2px;  width:15px; height:15px; line-height:14px; text-align:center; background:#fff; cursor:pointer; }
27         .slideBox .hd ul li.on{ background:#f00; color:#fff; }
28         .slideBox .bd{ position:relative; height:100%; z-index:0;   }
29         .slideBox .bd li{ zoom:1; vertical-align:middle; }
30         .slideBox .bd img{ width:450px; height:230px; display:block;  }
31 
32         /* 下面是前/后按钮代码,如果不需要删除即可 */
33         .slideBox .prev,
34         .slideBox .next{ position:absolute; left:3%; top:50%; margin-top:-25px; display:block; width:32px; height:40px; background:url(images/slider-arrow.png) -110px 5px no-repeat; filter:alpha(opacity=50);opacity:0.5;   }
35         .slideBox .next{ left:auto; right:3%; background-position:8px 5px; }
36         .slideBox .prev:hover,
37         .slideBox .next:hover{ filter:alpha(opacity=100);opacity:1;  }
38         .slideBox .prevStop{ display:none;  }
39         .slideBox .nextStop{ display:none;  }
40 
41         </style>
42 
43         <div id="slideBox" class="slideBox">
44             <div class="hd">
45                 <ul><li>1</li><li>2</li><li>3</li></ul>
46             </div>
47             <div class="bd">
48                 <ul>
49                     <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="http://www.mamicode.com/images/pic1.jpg" /></a></li>
50                     <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="http://www.mamicode.com/images/pic2.jpg" /></a></li>
51                     <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="http://www.mamicode.com/images/pic3.jpg" /></a></li>
52                 </ul>
53             </div>
54 
55             <!-- 下面是前/后按钮代码,如果不需要删除即可 -->
56             <a class="prev" href="javascript:void(0)"></a>
57             <a class="next" href="javascript:void(0)"></a>
58 
59         </div>
60 
61         <script type="text/javascript">
62         jQuery(".slideBox").slide({mainCell:".bd ul",autoPlay:true});
63         </script>
64 
65 
66 
67 </body>
68 </html>
69 <script type="text/javascript">
70 //百度统计代码
71 var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
72 document.write(unescape("%3Cscript src=http://www.mamicode.com/‘" + _bdhmProtocol + "hm.baidu.com/h.js%3Fa630f96b6a9dd549675d26373853f7f1‘ type=‘text/javascript‘%3E%3C/script%3E"));
73 </script>

效果图:

技术分享

这里用的是大话主席写的superslide框架,一个js特效的框架,能解决大部分轮播等问题。

附上superslide地址:http://www.superslide2.com/

JS——网页图片轮播特效