欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!

可点击竖立焦点切换幻灯片DIV+CSS+JS特效,自动切换图片幻灯片CSS特效图例代码+下载+在线演示。

自动切换图片幻灯片特效截图:

CSS幻灯片特效截图
自动切换幻灯片特效截图

此自动切换主要HTML代码:

  1. <div class="visit_15"><div id="tab-wrap"> 
  2.  <ul class="list"> 
  3.   <li> 
  4.    <a href=""><img src="1.jpg" width="980" height="179" alt="竖立点幻灯片特效" /></a>
  5.      <div class="bg-right"></div> 
  6.   </li> 
  7.   <li> 
  8.    <a href="http://www.divcss5.com/"><img src="2.jpg" width="980" alt="css学习" height="179" /></a>
  9.      <div class="bg-right"></div> 
  10.   </li> 
  11.   <li> 
  12.    <img src="3.jpg" width="980" height="179" />
  13.      <div class="bg-right"></div> 
  14.   </li> 
  15.   <li> 
  16.    <img src="4.jpg" width="980" height="179" />
  17.      <div class="bg-right"></div> 
  18.   </li> 
  19.   <li> 
  20.    <img src="5.jpg" width="980" height="179" />
  21.      <div class="bg-right"></div> 
  22.   </li> 
  23.  </ul> 
  24. </div> 
  25. </div> 

焦点竖立CSS代码

  1. body{ text-align:center} 
  2. *{margin:0;padding:0;list-style:none;} 
  3. .visit_15{width:980px; margin:0 auto;overflow:hidden; clear:both;} 
  4. isit_15 li{width:245px;float:left;} 
  5. #tab-wrap {width:980px;position:relative;overflow:hidden;} 
  6. #tab-wrap .list {position:relative;height:179px;} 
  7. #tab-wrap .list li {position:absolute;top:0;left:0;width:100%;height:180px;} 
  8. #tab-wrap .list li img {margin:0 auto;width:980px;} 
  9. #tab-wrap .list li .bg-right {position:absolute;top:0;right:0;width:50%;height:179px;z-index:-1;} 
  10. #tab-wrap .count {position:absolute;left:50%;width:10px;height:125px;top:75px;margin-left:470px;z-index:300;} 
  11. #tab-wrap .count li {float:left;width:10px;height:10px;background:#ccc;margin-bottom:10px;} 
  12. #tab-wrap .count li:hover{cursor:pointer;} 
  13. #tab-wrap .count li.current {background:#85BE2E;} 

此幻灯片CSS+JS特效的全部JS代码:

  1. <script type="text/javascript"> 
  2.   window.onload=function(){ 
  3.    var oTab=document.getElementById("tab-wrap"); 
  4.    var oList=oTab.getElementsByTagName("ul")[0]; 
  5.    var aLi=oTab.getElementsByTagName("li"); 
  6.    var aImg=oTab.getElementsByTagName("img"); 
  7.    var aDiv=oTab.getElementsByTagName("div"); 
  8.    var sWidth=aImg[0].offsetHeight; 
  9.    var iindex=i=0; 
  10.    var timer=playTimer=null; 
  11.    var bOrder=true
  12.    var aTmp=[]; 
  13.    var aLib=[0]; 
  14.    var aClor=[["#FFFFFF","#FFFFFF"],["#FFFFFF","#FFFFFF"],["#FFFFFF","#FFFFFF"],["#FFFFFF","#FFFFFF"],["#FFFFFF","#FFFFFF"]]; 
  15.    //DIVCSS5提示:有多少组图片,这里就有多少组,["#FFFFFF","#FFFFFF"] 
  16.    for(i=0;i<aLi.length;i++){ 
  17.     aTmp.push("<li></li>") 
  18.    } 
  19.    var oCount=document.createElement("ul"); 
  20.    oCount.className="count"
  21.    oCount.innerHTML=aTmp.join(""); 
  22.    oTab.appendChild(oCount); 
  23.    // 
  24.    var aBtn=oTab.getElementsByTagName("ul")[1].getElementsByTagName("li"); 
  25.    for(i=0;i<aBtn.length;i++){ 
  26.     aBtn[i].index=i; 
  27.     aBtn[i].onclick=function(){ 
  28.      index=this.index; 
  29.      aLib.push(index); 
  30.      if(aLib.length>2){aLib.shift()}; 
  31.      for(i=0;i<aBtn.length;i++){ 
  32.       aBtn[i].className=""
  33.       aLi[i].style.zIndex=100
  34.       aLi[i].style.display="none"
  35.      } 
  36.      aBtn[index].className="current"
  37.      aLi[index].style.zIndex=200
  38.      aLi[index].style.top=sWidth+"px"; 
  39.      aLi[index].style.display="block"
  40.      aLi[aLib[0]].style.display="block"
  41.      aLi[index].style.background=aClor[index][0]; 
  42.      aDiv[index].style.background=aClor[index][1]; 
  43.      if(aLib[0]!=aLib[1]){ 
  44.       showMove(aLi[index]) 
  45.      }else { 
  46.       aLi[index].style.top=0
  47.      } 
  48.       
  49.     } 
  50.    } 
  51.    // 
  52.    aBtn[index].className="current"
  53.    aLi[index].style.zIndex=200
  54.    aLi[index].style.background=aClor[index][0]; 
  55.    aDiv[index].style.background=aClor[index][1]; 
  56.    autoPlay(); 
  57.    // 
  58.    oTab.onmouseover=function(){ 
  59.     clearInterval(playTimer); 
  60.    } 
  61.    oList.onmouseout=function(){ 
  62.     autoPlay(); 
  63.    } 
  64.    // 
  65.    function autoPlay(){ 
  66.     playTimer=setInterval(function(){ 
  67.      index==aBtn.length-1 && (bOrder=false); 
  68.      index==0 && (bOrder=true); 
  69.      bOrder ? index++ : index--; 
  70.      //console.log(index); 
  71.      aBtn[index].onclick(); 
  72.     },5000) 
  73.    } 
  74.    // 
  75.    function showMove(obj){ 
  76.     clearInterval(timer); 
  77.     timer=setInterval(function(){ 
  78.      doMove(obj) 
  79.     },30) 
  80.    } 
  81.    // 
  82.    function doMove(obj){ 
  83.     var iSpeed=obj.offsetTop/10; 
  84.     iSpeediSpeed=iSpeed>0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); 
  85.     obj.offsetTop<=0 ? clearInterval(timer) : objobj.style.top=obj.offsetTop-iSpeed+"px"; 
  86.    } 
  87.   }  
  88.   </script> 

大家可直接复制以上代码即可使用。

在线示范:查看案例

在线下载:

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css-texiao/texiao568.shtml