91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

這么用原生js自動輪播展示產品圖片

發布時間:2022-03-14 17:18:46 來源:億速云 閱讀:153 作者:iii 欄目:web開發

今天小編給大家分享一下這么用原生js自動輪播展示產品圖片的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

代碼如下:

<!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=utf-8" />

<title>原生js自動輪播展示產品圖片</title>

<meta name="keywords" content="原生js,自動輪播,展示,產品圖片" />

<meta name="description" content="原生js自動輪播展示產品圖片" />

<link rel="stylesheet" type="text/css" href="css/style.css">

</head>

 

<body>

<div class="user_callback"> 

         <div class="user_pic" id="user_pic">  

                   <span class="prev"></span>   <span class="next"></span>  

                   <ul id="user_call">   

                            <li class="user_pic1">

                                     <a href="#"> <img src="images/57f8c4ccN6a433b82.png" alt="1" width="248" height="285" /></a>

                            </li>   

                            <li class="user_pic2">

                                     <a href="#"> <img src="images/57f8c4d6Nd425f6a3.png" alt="2" width="247" height="285" /></a>

                            </li>   

                            <li class="user_pic3">

                                     <a href="#"> <img src="images/57f8c4e1Nbd6f109e.png" alt="3" width="248" height="285" /></a>

                            </li>   

                            <li class="user_pic4">

                                     <a href="#"> <img src="images/57f8c4ecN92c22efc.png" alt="4" width="247" height="285" /></a>

                            </li>   

                            <li class="user_pic5">

                                     <a href="#"> <img src="images/583691e7Na26009a0.png" alt="5" width="247" height="285" /></a>

                            </li>   

                            <li class="user_pic6">

                                     <a href="#"> <img src="images/583691e7Ne2adc3c4.png" alt="6" width="247" height="285" /></a>

                            </li>   

                            <li class="user_pic7">

                                     <a href="#"> <img src="images/583691e7N058f6f5a.png" alt="7" width="247" height="285" /></a>

                            </li>   

                            <li class="user_pic8">

                                     <a href="#"> <img src="images/583691e7N36b67a44.png" alt="8" width="247" height="285" /></a>

                            </li>   

                   </ul> 

         </div>

</div>

<script type="text/javascript">function arcSlip()

  {

          var oPic=document.getElementById('user_pic');

          var oPrev=getByClass(oPic,'prev')[0];

          var oNext=getByClass(oPic,'next')[0];

          

          var aLi=oPic.getElementsByTagName('li');

          

          var arr=[];

          

          for(var i=0;i<aLi.length;i++)

          {

            var oImg=aLi[i].getElementsByTagName('img')[0];

           

                  arr.push([parseInt(getStyle(aLi[i],'left')),parseInt(getStyle(aLi[i],'top')),

                              getStyle(aLi[i],'zIndex'),oImg.width,parseFloat(getStyle(aLi[i],'opacity')*100)]);

          }

          

          

          oPrev.onclick=function moveTP()

          {

              arr.push(arr[0]);

                    arr.shift();

                        for(var i=0;i<aLi.length;i++)

                  {

                                 var oImg=aLi[i].getElementsByTagName('img')[0];

                                              

                                               aLi[i].style.zIndex=arr[i][2];

                                               startMove(aLi[i],{left:arr[i][0],top:arr[i][1],opacity:arr[i][4]});

                                               startMove(oImg,{width:arr[i][3]});

                             }

                           

          }

          

         oNext.onclick=function moveTN()

          {

               arr.unshift(arr[arr.length-1]);

                     arr.pop();

                        for(var i=0;i<aLi.length;i++)

                  {

                                 var oImg=aLi[i].getElementsByTagName('img')[0];

                                              

                                               aLi[i].style.zIndex=arr[i][2];

                                               startMove(aLi[i],{left:arr[i][0],top:arr[i][1],opacity:arr[i][4]});

                                               startMove(oImg,{width:arr[i][3]});

                             }

          }

    var moveTime = setInterval (function(){

        

                   oNext.click();

                  

                   },1000);

         $('#user_pic').hover(function(){

                   ;;

         clearInterval(moveTime);

            },function(){

        moveTime=setInterval(function(){ 

                   oNext.click();            

                   },1000);

            });

                                    

 function getStyle(obj,name)

          {

                if(obj.currentStyle){ return obj.currentStyle[name]; }

                      else{ return getComputedStyle(obj,false)[name]; }

          }

  }

function getByClass(oParent,sClass)

  {

      var aResult=[];

           var aEle=oParent.getElementsByTagName('*');

          

                     for(var i=0;i<aEle.length;i++)

                     {

                             if(aEle[i].className==sClass)

                             {

                                     aResult.push(aEle[i]);

                             }

                     }

           return aResult;

  }

function getStyle(obj,name)

  {

       if(obj.currentStyle)

            {

                return obj.currentStyle[name];

            }

      

            else

            {

                return getComputedStyle(obj,false)[name];

            }

  }

 function startMove(obj,json,fnEnd)

  {

       clearInterval(obj.timer);

       obj.timer=setInterval(function()

            {

                    var bStop=true;

                    for(var attr in json)

              {     

                               var cur=0;

        

                               if(attr=='opacity')

                               {

                                               cur=Math.round(parseFloat(getStyle(obj,attr))*100);

                               }

                               else

                               {

                                               cur=parseInt(getStyle(obj,attr));

                               }

                    

                               var  speed=(json[attr]-cur)/6;

                               speed=speed>0?Math.ceil(speed):Math.floor(speed);

                     

                               if(cur!=json[attr]) bStop=false;

                             

                               if(attr=='opacity')

                               {

                                        obj.style.filter='alpha(opacity:'+(cur+speed)+')';

                                        obj.style.opacity=(cur+speed)/100;

                               }

                               else

                               {

                                        obj.style[attr]=cur+speed+'px';

                               }

                    }

                    

                    if(bStop)

                    {

                        clearInterval(obj.timer);

                             if(fnEnd) fnEnd();

                    }

                    

            },30)

  }

  arcSlip();

</script>

</body>

</html>

以上就是“這么用原生js自動輪播展示產品圖片”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

js
AI

抚松县| 都江堰市| 南汇区| 大化| 科尔| 澄江县| 漳州市| 敦化市| 仙居县| 平乡县| 错那县| 望奎县| 彩票| 海门市| 康马县| 汾西县| 嵩明县| 凌源市| 洞口县| 贵阳市| 伊宁市| 多伦县| 郸城县| 瑞昌市| 宁都县| 搜索| 托克逊县| 专栏| 酒泉市| 固原市| 韩城市| 长宁县| 嘉善县| 阿克苏市| 衡山县| 山阴县| 温宿县| 绩溪县| 台前县| 大厂| 甘南县|