前端-SuperSlide轮播图圆点生成

.html

        <div class="slideBox">
            <div class="hd">
                <ul></ul>
            </div>
            <div class="bd">
                <ul>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic1.jpg" /></a></li>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic2.jpg" /></a></li>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic3.jpg" /></a></li>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic1.jpg" /></a></li>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic2.jpg" /></a></li>
                    <li><a href="http://www.SuperSlide2.com" target="_blank"><img src="images/pic3.jpg" /></a></li>
                </ul>
            </div>
            <!-- 下面是前/后按钮代码,如果不需要删除即可 -->
            <a class="prev" href="javascript:void(0)"></a>
            <a class="next" href="javascript:void(0)"></a>
        </div>

.css

        /* 本例子css */
        .slideBox{ width:450px; height:230px; overflow:hidden; position:relative; border:1px solid #ddd;  }
        .slideBox .hd{ height:15px; overflow:hidden; position:absolute; right:5px; bottom:5px; z-index:1; }
        .slideBox .hd ul{ overflow:hidden; zoom:1; float:left;  }
        .slideBox .hd ul li{ float:left; margin-right:2px;  width:15px; height:15px; line-height:14px; text-align:center; background:#fff; cursor:pointer; }
        .slideBox .hd ul li.on{ background:#f00; color:#fff; }
        .slideBox .bd{ position:relative; height:100%; z-index:0;   }
        .slideBox .bd li{ zoom:1; vertical-align:middle; }
        .slideBox .bd img{ width:450px; height:230px; display:block;  }

        /* 下面是前/后按钮代码,如果不需要删除即可 */
        .slideBox .prev,
        .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;   }
        .slideBox .next{ left:auto; right:3%; background-position:8px 5px; }
        .slideBox .prev:hover,
        .slideBox .next:hover{ filter:alpha(opacity=100);opacity:1;  }
        .slideBox .prevStop{ display:none;  }
        .slideBox .nextStop{ display:none;  }

.js

        <script type="text/javascript">  
                var banner = $(".slideBox > .bd > ul").children('li');
                for(var i = 0 ; i< banner.length ;i++){
                    $(".slideBox > .hd > ul").append('<li></li>');
                };
                $(".slideBox > .hd > ul").children('li').eq(0).addClass('on');
                $(".slideBox").slide({mainCell:".bd ul",autoPlay:true});
        </script>

使用了 jq语法,先拿到 banner轮播图的长度,在创建li添加到 控制元素 ul中

上一篇:JAVA批量文件下载


下一篇:Spring源码剖析1:初探Spring IOC核心流程