• 原生js轮播图


    //用原生js实现了一个简单的轮播图效果

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
    *{
    margin: 0;
    padding: 0;
    }
    #banner{
    position: relative;
    }
    #list{
    750px;
    height: 500px;
    margin: 100px auto;
    }
    #list img{
    display: block;
    }
    #list1{
    position: absolute;
    bottom: 10px;
    left: 50%;
    margin-left: -75px;
    }
    #list1 li{
    list-style: none;
    20px;
    height: 20px;
    border-radius: 20px;
    background: #000;
    opacity: .4;
    filter: alpha(opacity = 40) ;
    float: left;
    margin-left:10px ;
    cursor: pointer;
    }
    #banner a{
    display: block;
    30px;
    height: 30px;
    background: #000;
    opacity: .4;
    position: absolute;
    top: 50%;
    margin-top: -15px;
    text-decoration: none;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    line-height: 30px;
    text-align: center;
    }
    #left{
    left: 21%;
    }
    #right{
    right: 21%;
    }
    #list1 .li{
    background: #f40;
    }
    #box{
    750px;
    height: 500px;
    margin: 0 auto;
    }
    </style>
    </head>
    <body>
    <div id="banner">
    <div id="box">
    <div id="list">
    <img id="pic" src="img/1.jpg" />
    </div>
    <a href="javascript:;" id="left"><</a>
    <a href="javascript:;" id="right">></a>
    </div>
    <ul id="list1">
    <li class="li"></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
    </div>
    <script type="text/javascript">
    var oList = document.getElementById("list");
    var oList1 = document.getElementById("list1");
    var oLi = document.getElementsByTagName('li');
    var oPic = document.getElementById("pic");
    var Left = document.getElementById("left");
    var Right = document.getElementById("right");
    var box = document.getElementById("box");
    num = 1;
    var timer = setInterval(function(){
    num++;
    if(num>5){
    num=1;
    }
    fn();
    },2000)
    oList.onmouseout = function(){
    timer = setInterval(function(){
    num++;
    if(num>5){
    num=1;
    }
    fn();
    },2000)
    }
    box.onmouseover = function(){
    clearInterval(timer);
    }
    Right.onclick = function(){
    num++;
    if(num>5){
    num =1;
    }
    fn();
    }
    Left.onclick = function(){
    num--;
    if(num<1){
    num = 5;
    }
    fn();
    }
    for (var i=0;i<oLi.length;i++) {
    oLi[i].index = i;
    oLi[i].onclick = function(){
    num = this.index+1;
    fn();
    }
    }
    function fn(){
    oPic.src = "img/"+num+".jpg";
    for (var i=0;i<oLi.length;i++) {
    oLi[i].className = '';
    if(num == i+1){
    oLi[i].style.background = '#f40';
    }else{
    oLi[i].style.background = '';
    }
    }
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    阿里笔试题—战报交流
    2 基于梯度的攻击——PGD
    1 基于梯度的攻击——FGSM
    0 对抗样本
    自然语言处理 复习笔记 3
    自然语言处理 复习笔记 2
    自然语言处理 复习笔记 1
    GRU
    1*1卷积核的作用
    BP原理
  • 原文地址:https://www.cnblogs.com/zzgyq/p/banner.html
Copyright © 2020-2023  润新知