大图轮播完整流程代码操作:

<style>
            * {
                margin: 0px;
                padding: 0px;
            }
            
            .stage {
                width: 500px;
                height: 300px;
                border: 5px solid black;
                margin: 200px;
                position: relative;
                overflow: hidden;
            }
            
            .to-left,
            .to-right {
                position: absolute;
                top: 0px;
                width: 50px;
                height: 300px;
                background-color: black;
                color: white;
                font-size: 30px;
                text-align: center;
                line-height: 300px;
                opacity: 0.3;
            }
            
            .to-left {
                left: 0px;
            }
            
            .to-right {
                right: 0px;
            }
            
            .to-left:hover,
            .to-right:hover {
                cursor: pointer;
                opacity: 0.5;
            }
            
            .banner {
                width: 3000px;
                height: 300px;
            }
            
            .items {
                float: left;
                width: 500px;
                height: 300px;
                background-color: blanchedalmond;
                font-size: 100px;
                text-align: center;
                line-height: 300px;
            }
        </style>
    </head>
<!--大图轮播特效-->
    <body>
        <div class="stage">
            <div class="to-left">
                <</div>
                    <div class="to-right">></div>
                    <div class="banner">
                        <div class="items">1</div>
                        <div class="items" style="">2</div>
                        <div class="items" style="">3</div>
                        <div class="items" style="">4</div>
                        <div class="items" style="">5</div>
                        <div class="items">1</div>
                    </div>
            </div>
    </body>

</html>
<script>
    var to_right = document.getElementsByClassName('to-right')[0];
    var to_left = document.getElementsByClassName('to-left')[0];
    var banner = document.getElementsByClassName('banner')[0];
    var arr = [];
    var count = 1;

    to_right.onclick = function() {
        toRight();
    }
    
    function toRight(){
        arr.push(window.setInterval("moveLeft()", 30));
    }
    
    to_left.onclick = function() {
        toLeft();
    }

    function toLeft(){
        arr.push(window.setInterval("moveRight()", 30));
    }
    
    function moveLeft() {
        if(count < 5) {
            if(banner.offsetLeft > count * (-500)) {
                banner.style.marginLeft = banner.offsetLeft - 20 + "px";
            } else {
                for(var x in arr) {
                    window.clearInterval(arr[x]);
                }
                count++;
            }
//    连接点
        }else{
            if(banner.offsetLeft > count * (-500)) {
                banner.style.marginLeft = banner.offsetLeft - 20 + "px";
            } else {
                for(var x in arr) {
                    window.clearInterval(arr[x]);
                }
                count = 1;
                banner.style.marginLeft = 0 + 'px';
            }
        }
    }
    
    function moveRight() {
        if(count-1 >0) {
            if(banner.offsetLeft < (count-2) * (-500)) {
                banner.style.marginLeft = banner.offsetLeft + 20 + "px";
            } else {
                for(var x in arr) {
                    window.clearInterval(arr[x]);
                }
                count--;
            }
        }
    }
    window.setInterval("toRight()",1750);
    

</script>

最新文章

  1. 基础总结之Activity
  2. js 根据屏幕大小调用不同的css文件
  3. NK3C:关于svg文件使用
  4. java程序 启动时参数
  5. 【开源】分享一个前后端分离方案-前端angularjs+requirejs+dhtmlx 后端asp.net webapi
  6. Linux_磁盘管理
  7. 修改apache的默认访问目录
  8. JavaScript中Math--random()/floor()/round()/ceil()
  9. [原创]gerrit上分支操作记录(创建分支、删除分支)
  10. 【BZOJ】1008: [HNOI2008]越狱(快速幂)
  11. CSS笔记(十五)CSS3之用户界面
  12. Android 中建立一个OpenGL ES的开发环境
  13. HTML 转义符
  14. Angular2中的metadata(元数据)
  15. Power Station POJ 4045
  16. Excel Skill (1) -- 判断时如何去掉框里的空格
  17. android源码地址及下载介绍
  18. 测试员浅谈App测试的重点
  19. Linux 下安装jetty服务器
  20. Python基础之元组和字典

热门文章

  1. Vulkan Tutorial 25 Images
  2. JDBC02 利用JDBC连接数据库【使用数据库连接池】
  3. c++ 命名空间 以及 作用域 函数参数 面向对象实验报告
  4. dfs.datanode.max.transfer.threads
  5. MongoDB数据库基础操作
  6. H5读取本地文件操作
  7. 第2章 rsync算法原理和工作流程分析
  8. java数组排序(冒泡、直排)反转
  9. GetStdHandle 函数--获取标准设备的句柄
  10. node 简介 起源