zoukankan      html  css  js  c++  java
  • slider(前一张 后一张 prev next)

    
    
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>prev next选择</title>
    <style>
    #banner{height: 330px; 980px;border: 1px solid #ffaf0f;overflow: hidden;position: relative;top: 50px;left: 100px}
    #banner .table{ inherit;height: inherit;position:relative;margin: 0px -50px}
    #banner .table li{list-style: none;float: left}
    #prev{position: absolute;left: 1100px;top: 200px; background: url("prev.png")no-repeat ;border-radius: 50%; 75px;height: 71px}
    #next{position: absolute;left: 20px;top: 200px;
    ;background: url("next.png") no-repeat 0.5px 0.5px;border-radius: 50%; 75px;height: 71px}
    </style>
    </head>
    <body>
    <div id="banner">
    <ul class="table">
    <li><a href="#" target="_blank"><img src="2.1.png" title=""> </a> </li>
    <li><a href="#" target="_blank"><img src="2.2.png" title=""> </a> </li>
    <li><a href="#" target="_blank"><img src="2.3.png" title=""> </a> </li>
    <li><a href="#" target="_blank"><img src="2.4.png" title=""> </a> </li>
    <li><a href="#" target="_blank"><img src="2.5.png" title=""> </a> </li>
    <li><a href="#" target="_blank"><img src="2.6.png" title=""> </a> </li>
    </ul>

    </div>
    <button id="prev" onclick="next()"></button>
    <button id="next" onclick="prev()"></button>
    </body>
    <script type="text/javascript" src="jquery-3.1.1.min.js"></script>
    <script type="text/javascript">

    //var intervalObj = window.setInterval(next,500);/*用于轮播*/
    var len =$(".table li").length,
    liW = $(".table li").outerWidth(true);
    $(".table").css("width",len*liW);
    function next() {
    $(".table li:first-child").animate({
    marginLeft:"-980px" /*移动多少*/
    },1000,function () {
    var tem = $(this).clone();/*克隆函数*/
    $(this).remove();/*删除*/
    tem.css({marginLeft:"0"});
    $(".table").append(tem);/*添加到头部*/
    });
    }
    function prev() {
    var tem = $(".table li:last-child").clone();
    $(".table li:last-child").remove();
    tem.css({ marginLeft:"-980px"});
    $(".table").prepend(tem);
    $(".table li:first-child").animate({marginLeft:"0"},1000);
    }


    </script>
    </html>
     
  • 相关阅读:
    解决IE新开窗口无法显示内容的问题
    日历控件
    关于索引,我们可以知道的更多 全表扫描和索引扫描
    C#构造函数的小说明
    动态创建的组件的ID设定
    正则表达式使用详解
    “运行”命令全集
    数组型参数
    接口实现的继承机制
    读取XML文件
  • 原文地址:https://www.cnblogs.com/html-css-js/p/6640580.html
Copyright © 2011-2022 走看看