zoukankan      html  css  js  c++  java
  • 轮播图

    凡遇到网页百分之九十九点九九都会遇到轮播图,

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
    #banner{
    500px;
    height: 300px;
    border: #008877 solid 3px;
    }
    #ad{
    200px;
    height: 140px;
    border: 3px solid #FF4400;
    }
    </style>
    </head>
    <body>
    <div id="banner">
    </div>
    <br>
    <br>
    <div id="ad">
    </div>
    <script type="text/javascript">
    function Lunbo(options){
    this.el = document.querySelector(options.el);
    this.data = options.data;
    this.pagination = options.pagination || false;
    this.toggleBtn = options.toggleBtn || false;
    this.time = options.time || 2000

    this.view();
    this.toggle();
    }
    Lunbo.prototype = {
    view(){
    this.el.style.position = "relative";
    this.data.forEach(i=>{
    let img = document.createElement("img")
    img.src = i;
    img.style.width = "100%";
    img.style.height = "100%";
    img.style.position = "absolute";
    img.style.top = 0;
    img.style.left = 0;
    this.el.appendChild(img)
    })
    },
    toggle(){
    let i = 0;
    setInterval(()=>{
    i++;
    if(i>this.data.length-1){
    i=0
    }
    [...this.el.children].forEach(j=>{
    j.style.zIndex = 0
    })
    this.el.children[i].style.zIndex = 1
    },this.time)
    }
    }
    let L1 = new Lunbo({
    el:"#banner",
    data:["../image/01.jpg","../image/02.jpg","../image/03.jpg","../image/04.jpg"],
    pagination:true,
    toggleBtn:true,
    time:1500
    })
    let L2 = new Lunbo({
    el:"#ad",
    data:["../image/04.jpg","../image/03.jpg","../image/02.jpg","../image/01.jpg"],
    time:3000
    })
    </script>
    </body>
    </html>

    效果图:

  • 相关阅读:
    Unity 2018 version class.jar path
    GitHub git
    QT install
    Android Studio 安装及汉化
    Unity 调用android
    JAVA 调用c++ 扩展 批评那些垃圾,
    JAVA java调用C++动态链接库dll,有详细过程。VS2015+Eclipse以及失败解决方案
    前端将数据转化为弹幕效果的实现方式
    css圣杯布局的实现方式
    浏览器缓存问题原理以及解决方案
  • 原文地址:https://www.cnblogs.com/leitongtong/p/13879347.html
Copyright © 2011-2022 走看看