日期:2014-05-16 浏览次数:20412 次
<!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> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>焦点图</title> <style type="text/css"> #focus_box{ width:530px; height:180px; position:relative; margin:0 auto; overflow:hidden; zoom:1;} #focus_box ul{ list-style:none; padding:0; margin:0;} #focus_btn{ position:absolute; right:5px; bottom:5px; z-index:2;} #focus_pic{ position:absolute;} #focus_pic li{ height:180px; width:530px; margin:0; padding:0;} #focus_btn li{ float:left; font-size:12px; width:25px; height:25px; line-height:25px; font-weight:bold; text-align:center; background:#fff; color:#000; margin-right:2px; cursor:pointer;} #focus_btn li.on{ background:#f60; color:#fff;} img{border:none; margin:0;padding:0; disaplay:block;} </style> </head> <body> <div id="focus_box" > <ul id="focus_pic" style="left:0;top:0;"> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111201/530_180.jpg" width="530" height="180"></a></li> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111202/530_180.jpg" width="530" height="180"></a></li> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111205/530_180.jpg" width="530" height="180"></a></li> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111201/530_180.jpg" width="530" height="180"></a></li> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111202/530_180.jpg" width="530" height="180"></a></li> <li><a target="_blank" href="#"><img src="http://img.fqmall.cn/WebResources/boc/Xdv/shopping/images/20111205/530_180.jpg" width="530" height="180"></a></li> </ul> <ul id="focus_btn"> <li class="">1</li> <li class="">2</li> <li class="">3</li> <li class="">4</li> <li class="">5</li> <li class="">6</li> </ul> </div> <script type="text/javascript"> (function(){ var picHeight = 180;//幻灯片的高度 var picWidth = 530;//幻灯片的宽度 var autoTime = 1000;//自动播放间隔时间 var index = 0; //从第几个开始轮播,0为第一个 var v = 1;//1为垂直播放,0为水平播放 var focusPics = document.getElementById("focus_pic");//获得幻灯片的框架ID var focusLi = focusPics.getElementsByTagName("li"); var picNo = focusLi.length;//幻灯片的数量 var Timer,autoTimer; var posX,posY;//移动的目标距离 var focus_btn = document.getElementById("focus_btn"); var btnLi = focus_btn.getElementsByTagName("li"); btnLi[0].className = "on"; if(v==0){//当方向为水平移动时候 focusPics.style.width = picNo*picWidth + "px"; //设置包裹UL的宽度为LI的数量乘以图片的宽度 for(var i=0;i<picNo;i++){//设置样式 focusLi[i].style.float = "l