<!DOCTYPE html><html><head> <title>focus</title> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script> <style type="text/css"> *{padding:0;margin: 0;} li{list-style: none;} #pic_box{ width: 500px; height: 300px; position: relative; margin: 100px; overflow: hidden; } #pic{ width: 2000px; height: 300px; position: absolute; left:0; top: 0; } #pic li{ width: 500px; height: 300px; float: left; } #pic li img{ width: 500px; height: 300px; } #nav{ position: absolute; left: 50%; margin-left: -90px; bottom: 40px; } #nav a{ float: left; width: 20px; height: 10px; margin-left: 20px; background: #ccc; } </style></head><body><div id="pic_box"> <ul id="pic"> <li><img src="images/P_03.jpg"></li> <li><img src="images/P_09.jpg"></li> <li><img src="images/P_011.jpg"></li> <li><img src="images/P_016.jpg"></li> </ul> <div id="nav"> <a href="#"></a> <a href="#"></a> <a href="#"></a> <a href="#"></a> </div></div><script type="text/javascript"> $(function(){ var count=0; $("a").click(function(){ $("#pic").css.left=-$(this).index()*500+'px'; }); setInterval(focus,1000); function focus(){ count++; $("#pic").css.left=-count*500+'px'; } }); </script></body></html>
輪播圖為什么實(shí)現(xiàn)不了
慕哥6327088
2017-01-13 14:47:28