国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > JS > 正文

JavaScript實(shí)現(xiàn)大圖輪播效果

2024-05-06 16:34:31
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了js圖片輪播效果的具體代碼,供大家參考,具體內(nèi)容如下

<head>  <head>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />    <title>大圖輪播</title>    <style type="text/css">      * {        margin: 0px;        padding: 0px;      }            #container {        width: 500px;        height: 300px;        /*border: 1px solid black;*/        position: relative;        overflow: hidden;      }            .btn {        height: 100%;        width: 30px;        /*border: 1px solid red;*/        position: absolute;        text-align: center;        line-height: 300px;        font-size: 40px;        font-weight: 900;        color: black;        opacity: 0.3;        transition: 0.6s;        z-index: 999;        background-color: white;      }            .btn:hover {        cursor: pointer;        opacity: 0.8;      }            #left-btn {        left: 0px;        top: 0px;      }            #right-btn {        right: 0px;        top: 0px;      }            #ad-container {        width: 2500px;        height: 300px;        /*border: 1px solid blue;*/        position: relative;      }            .ad {        width: 500px;        height: 300px;        float: left;        text-align: center;        line-height: 300px;        font-size: 100px;        font-family: "微軟雅黑";      }    </style>  </head>  <body>    <div id="container">      <div id="left-btn" class="btn">        <</div>          <div id="right-btn" class="btn">></div>          <div id="ad-container">            <div class="ad" style="background-color: mediumpurple;">1</div>            <div class="ad" style="background-color: yellowgreen;">2</div>            <div class="ad" style="background-color: rosybrown;">3</div>            <div class="ad" style="background-color: salmon;">4</div>            <div class="ad" style="background-color: cyan;">5</div>          </div>      </div>  </body></html><script type="text/javascript">  var rightBtn = document.getElementById("right-btn");  var leftBtn = document.getElementById("left-btn");  var n = 1;/*  var count = 1*/;  var arr = new Array();/*  var m=1;*/  rightBtn.onclick = function() {    var x = window.setInterval("to_right()", 20);    arr.push(x);  }  function clear() {    for(var i in arr) {      window.clearInterval(arr[i]);    }  }  function to_right() {    var adContainer = document.getElementById("ad-container");    if(n == 5) {      clear();    } else if(adContainer.offsetLeft != n * (-500)) {      adContainer.style.marginLeft = adContainer.offsetLeft - 25 + "px";    } else {      n++;      clear();    }  }  var arr1 = new Array();  leftBtn.onclick = function() {    var y = window.setInterval("to_left()", 20);    arr1.push(y);  }  function clear2() {    for(var y in arr1) {      window.clearInterval(arr1[y]);    }  }  function to_left() {    var adContainer = document.getElementById("ad-container");    if(n == 1) {      clear2();    } else if(adContainer.offsetLeft != (n-2) * (-500)) {      adContainer.style.marginLeft = adContainer.offsetLeft + 25 + "px";    } else {      n--;      clear2();    }  }  </script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JavaScript/Ajax教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 炉霍县| 密山市| 文成县| 水富县| 张家港市| 和龙市| 类乌齐县| 永顺县| 新沂市| 睢宁县| 延寿县| 绥芬河市| 汝阳县| 西乌珠穆沁旗| 会昌县| 津南区| 滨州市| 吴忠市| 锦州市| 始兴县| 渑池县| 新田县| 尼玛县| 陇南市| 阿拉尔市| 邮箱| 饶阳县| 伊吾县| 石首市| 新绛县| 莒南县| 武邑县| 宁德市| 陵水| 中山市| 临沂市| 海门市| 无锡市| 松桃| 莱西市| 喀喇沁旗|