<!DOCTYPE html>
<html>

<head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            * {
                margin: 0px;
                padding: 0px;
            }
            
            #stage {
                width: 400px;
                height: 40px;
                border: 3px solid black;
                margin: 100px;
                overflow: hidden;
                position: relative;
            }
            
            #banner {
                width: 2400px;
                height: 300px;
                background-color: rosybrown;
            }
            
            .items {
                width: 400px;
                height: 40px;
                color: white;
                font-size: 25px;
                text-align: center;
                line-height: 300px;
                float: left;
            }
            
            .btn-l,
            .btn-r {
                width: 50px;
                height: 300px;
                background-color: black;
                opacity: 0.5;
                color: white;
                font-size: 40px;
                line-height: 300px;
                text-align: center;
                position: absolute;
                top: 0px;
            }
            
            .btn-l {
                left: 0px;
            }
            
            .btn-r {
                right: 0px;
            }
            
            .btn-l:hover,
            .btn-r:hover {
                cursor: pointer;
                /*透明度*/
                opacity: 0.2;
            }
        </style>
    </head>

<body>
        <div id="stage">
            <div class="btn-l">
                <</div>
                    <div class="btn-r">></div>
                    <div id="banner">
                        <div class="items" style="">平洋房产真实房源xxxx套</div>
                        <div class="items" style="">平阳房产真实在线交易xxxx套</div>
                        <div class="items" style="">平阳房产真实在线交易xxxx套</div>
                        <div class="items" style="">平阳房产真实在线交易xxxx套</div>
                        <div class="items" style="">平阳房产真实在线交易xxxx套</div>
                        <div class="items" style="">平洋房产真实房源xxxx套</div>
                    </div>
            </div>
    </body>

</html>
<script>
    var btn_l = document.getElementsByClassName('btn-l')[0];
    var btn_r = document.getElementsByClassName("btn-r")[0];
    var banner = document.getElementById("banner");
    var count = 1;
    var arr = [];

btn_r.onclick = function() {
        if(count < 6) {
            count++;
            arr.push(window.setInterval("move_left()", 20));
        } else if(count == 6) {
            count = 1;
            banner.style.marginLeft = 0 + "px";

count++;
            arr.push(window.setInterval("move_left()", 20));
        }
    }

btn_l.onclick = function() {
        if(count > 1) {
            count--;
            arr.push(window.setInterval("move_right()", 20));
        } else if(count = 1) {
            count = 5;
            banner.style.marginLeft = -2000 + "px";

count++;
            arr.push(window.setInterval("move_left()", 20));
        }
    }

function move_left() {
        if(banner.offsetLeft == (count - 1) * (-400)) {
            clear();
        } else {
            banner.style.marginLeft = banner.offsetLeft - 20 + "px";
        }
    }

function move_right() {
        if(banner.offsetLeft == (count - 1) * (-400)) {
            clear();
        } else {
            banner.style.marginLeft = banner.offsetLeft + 20 + "px";
        }
    }

function clear() {
        for(var x in arr) {
            window.clearInterval(arr[x]);
        }
    }
    //-----------------------------    分割线--------------------------------
</script>

<!--0     -500       -1000      -1500      x
1   0    2           3         4        n-->

最新文章

  1. MySql大数据量恢复
  2. 对于EL表达式和ONGL表达式区别的相关理解
  3. Scrum4.0
  4. 利用FFmpeg生成视频缩略图 2.3.1
  5. &#39;UIShell.OSGi.MvcWebExtension.BundleRuntimeControllerFactory&#39; did not return a controller for the name &#39;Home&#39;.
  6. linux安装lua相关编译报错
  7. c++ 异常处理 assert | try
  8. hdu 1698 线段树成段更新
  9. 让AllocateHwnd接受一般函数地址作参数(105篇博客)
  10. 利用KindEditor实现公司通讯录的维护
  11. win10上使用Xshell通过ssh连接Linux
  12. 【转】/bin/bash^M: bad interpreter: No such file or directory
  13. Java数据库操作(MySQL与SQLserver)
  14. 从零开始学安全(二十七)●利用Nmap对防火墙,IDS,IPS 进行欺骗
  15. h5 端图片上传-模拟多张上传
  16. MySQL日常运维操作---持续更新
  17. va_start(),va_end()函数应用【转】
  18. 1067: 密室寻宝(find)
  19. 入门redis
  20. 面试准备——(五)Jmeter

热门文章

  1. Mac下安装OpenCV3.0和Anaconda和环境变量设置
  2. linux df -h显示空间信息不正确
  3. git常用命令(二)
  4. chrome 浏览器插件开发(二)—— 通信 获取页面变量 编写chrome插件专用的库
  5. 日常运维管理技巧一(查看负载 W)
  6. 理解css中的position属性
  7. java对一个int数组进行排序、去重
  8. BFS算法入门--POJ3984
  9. Ansible学习 Playbooks_1
  10. linux下载利器之curl和wget的区别