主にタイマー、バインド、トリガー アプリケーションなどの原理を使用します。 コードをコピーします コードは次のとおりです。 banner切换实现 <br> /*<br> * @description: banner切换样式<br> * @author: lanfeng(beryl)<br> * @time:2013-02-26<br> */<br> /* reset*/<br> *{ margin: 0; padding: 0;}<br> body{font:12px/1.5 Tahoma,'\5B8B\4F53',arial,Tahoma,helvetica,sans-serif; color:#333333;background-color:#ffffff;position:relative; }<br> h1,h2,h3,h4,h5,h6{font-size:100%}<br> address,em{font-style:normal;}<br> code,kbd,pre,samp{font-family:courier new,courier,monospace;}<br> ul,ol{list-style:none outside none;}<br> fieldset,img{border:0;}<br> img{vertical-align:middle}<br> table{border-collapse:collapse;border-spacing:0;font-size:inherit;*font-size:100%;}<br> input,button,textarea,select{vertical-align:middle;font:100% Helvetica,Arial,sans-serif; color:inherit}<br> .clearfix:after{content:'.';display:block;height:0;clear:both;visibility:hidden;}<br> .clearfix{*zoom:1;}<br> .clear{font-size:0;line-height:0;height:0;clear:both;visibility:hidden;overflow:hidden;} <p> .d-ftab{ width:510px; height: 180px;position: relative; margin: 100px auto;}<br> .d-fShow ul li{ float: left; width: 510px; height: 180px;}<br> .d-fShow{ width: 510px; height: 180px; overflow: hidden;}<br> .d-fShow img{ width: 510px; height: 180px; float: left;}<br> .d-fs-control{ position: absolute; width:510px; position: absolute; left: 0; bottom: 0; height: 25px; line-height: 25px;</p> <p><br>background: rgba(0,0,0,0.4);<br> filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#66000000',</p> <p>EndColorStr='#66000000') ; }<br> :root .d-fs-control{filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#66000000'</p> <p>,EndColorStr='#66000000')\9 ;}<br> .d-fs-control ul{ position: absolute; bottom:3px; right: 5px; height: 16px;}<br> .d-fs-control ul li{width:16px;height:16px; background:#777675;border-radius: 2px 2px 2px 2px; float:left;margin-left:5px;</p> <p>color:#dcdcdc;text-align:center;font-weight:700;cursor:pointer;line-height:16px;filter: alpha(opacity=70); opacity: 0.7;}<br> .d-fs-control ul li:hover,.d-fs-control ul li.select{background:#ffffff;color:#ff6700;}</p> <p> <br> $(function(){<br> var wrap =$('.d-ftab');<br> var imgs = wrap.find('.d-fShow ul >li');<br> var len=imgs.length ;<br> var tabTime=100;<br> var outTime=4000;<br> var select='select';<br> var num =0 ;<br> var interval;<br> var type = 'click';<br> var btns=wrap.find('.d-fs-control ul>li');<br> btns.bind(type,function(){<br> var _this=$(this);<br> _this.addClass('select').siblings ().removeClass('select');<br> num=_this.prevAll().length;<br> imgs.stop().eq(num).fadeTo(tabTime,1) ;<br> imgs.not(':eq('+num+')').filter(':visible').fadeOut(tabTime) ;<br> return false;<br>}).eq(num).trigger(type);<br> var interFunc=function(){<br> num=(num+1)%len;<br> btns.eq(num).triggerHandler(type);<br> }<br> wrap.bind('mouseover',function(){<br> clearInterval(interval);<br> }).bind('mouseout',function(){<br> interval=setInterval(interFunc,outTime)<br> })</p> <p> })<br> < a href="">< img alt="" src="images/4.jpg"> div> 1 2 3 4 5 效果如下图: