jquery.imageScroller实现图片滚动
jQuery的一个不错的小插件,jquery.imageScroller.js代码:复制代码在线演示:
如果您不想当成插件来用,里面的代码也可以单独扒出来(麦考林首页就是这么用的)
- <!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>jQuery无缝滚动</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
- <script type="text/javascript" src="http://img.rbtvs.com/js/jquery.imageScroller.js"></script>
- <style type="text/css">
- *
- {
- list-style: none;
- font-size: 12px;
- padding: 0;
- margin: 0;
- }
-
- #list li
- {
- width: 90px;
- height: 18px;
- line-height: 18px;
- text-align: center;
- padding: 41px 0;
- float: left;
- margin: 0 5px;
- background-color: Aqua;
- }
-
- #btnPrev, #btnNext, #listBox
- {
- float: left;
- }
-
- #btnPrev, #btnNext
- {
- width: 30px;
- height: 18px;
- line-height: 18px;
- padding: 41px 0;
- background: #ff9;
- text-align: center;
- }
-
- #listBox
- {
- width: 400px;
- height: 100px;
- overflow: hidden;
- background: #000;
- }
-
- #container
- {
- width: 460px;
- height: 100px;
- background: red;
- position: absolute;
- left: 50%;
- top: 50%;
- margin-left: -230px;
- margin-top: -50px;
- }
- </style>
- <script type="text/javascript">
- $(function () {
- $("#listBox").imageScroller({
- next: "btnNext",
- prev: "btnPrev",
- frame: "list",
- child: "li",
- auto: true
- });
- });
- </script>
- </head>
- <body>
- <div id="container">
- <div id="btnNext" title="上一个">
- <<
- </div>
- <div id="listBox">
- <ul id="list">
- <li>001</li>
- <li>002</li>
- <li>003</li>
- <li>004</li>
- <li>005</li>
- <li>006</li>
- <li>007</li>
- <li>008</li>
- <li>009</li>
- </ul>
- </div>
- <div id="btnPrev" title="下一个">
- >>
- </div>
- </div>
- </body>
- </html>
如果您不想当成插件来用,里面的代码也可以单独扒出来(麦考林首页就是这么用的)