• 仿制视频播放滚动条效果(加左右控制按钮)


    仿制视频播放滚动条效果(加左右控制按钮)

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>12313</title>
    <style type="text/css">
    *{margin:0;padding:0;}
    ul,li{list-style:none;}
    img{border:0;}
    a{text-decoration:none;}
    .wrapper{position:relative;600px;height:140px;margin:0 auto;border:1px solid red;overflow:hidden;}
    .wrapper ul{position:absolute;top:4px;left:0;height:100px;}
    .wrapper ul li{float:left;padding-right:20px;line-height:100px;text-align:center;}
    .wrapper ul li a{display:block;100px;height:100px;background:#ccc;}
    .lineDiv{position:relative;height:1px;overflow:hidden;}
    .lineBtn{position:absolute;top:110px;left:0;80px;height:20px;background:#c9b07b;text-align:center;line-height:20px;cursor:pointer;}
    .left{position:absolute;top:35px;left:-10px;40px;height:40px;background:#64afde;line-height:40px;text-align:center;cursor:pointer;}
    .right{position:absolute;top:35px;left:560px;40px;height:40px;background:#64afde;line-height:40px;text-align:center;cursor:pointer;}
    </style>
    </head>
    <body>
    <div class="wrapper" id="wrapper">
        <ul>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
            <li><a href="#" target="_blank">1111</a></li>
        </ul>
        <div class="lineBtn" id="lineBtn">btn</div>
        <div class="left" id="left">&lt;</div>
        <div class="right" id="right">&gt;</div>
    </div>
    <script type="text/javascript">
    window.onload = function(){
         var owrapper = getId("wrapper");
        var olineBtn = getId("lineBtn");
        var oleft = getId("left");
        var oright = getId("right");
        var oLi = getDom("li",owrapper);
        owrapper.children[0].style.width = oLi.length*oLi[0].offsetWidth + "px";
        var owLeft = owrapper.offsetLeft;
        olineBtn.style.width = owrapper.children[0].clientWidth - owrapper.clientWidth +"px";
        var disX = 0,moveLeft = 0;
        olineBtn.onmousedown = function(e){
             var oEvent = e || event;
             var curWidth = oEvent.layerX?oEvent.layerX:oEvent.offsetX;
             disX =  owrapper.offsetLeft + curWidth;
             document.onmousemove = function(e){
                 divMove(e);
             }
        }
        document.onmouseup = function(){
            document.onmousemove = null;
        }
        oleft.onclick = function(e){
            moveLeft-=10;
            divMove(e,moveLeft);
        }
        oright.onclick = function(e){
            moveLeft+=10;
            divMove(e,moveLeft);    
        }
        
        function divMove(e,movestep){
            var oEvent = e || event;
            moveLeft = movestep?movestep:(oEvent.clientX - disX);
            if(moveLeft <= 0 ){
                moveLeft = 0;
            }else if(moveLeft >= owrapper.clientWidth-olineBtn.clientWidth ){
                moveLeft = parseInt(owrapper.clientWidth-oLi.clientWidth)+"px";
            }
            olineBtn.style.left = moveLeft + "px";
            owrapper.children[0].style.left = - moveLeft + "px";
        }
    }    
    function getStyle(obj,attr){
        return obj.currentStyle?parseInt(obj.currentStyle[attr]):parseInt(getComputedStyle(obj,false)[attr]);
    }
    function getDom(dom,obj){
        obj = obj || document;
        return obj.getElementsByTagName(dom);
    }
    function getId(id){
        return document.getElementById(id)
    }
    </script>
    </body>
    </head>
    </html>

  • 相关阅读:
    Azure Pipelines —— 资料合集
    training —— Applying Functional(函数式编程) Principles in C# 6 (overview)
    Mongodb 学习路线
    training_ Refactoring from Anemic Domain Model Towards a Rich One (Introducing an Anemic Domain Model)
    快速访问电脑软件的 辅助app—— PowerToys
    NoSQL
    AWS
    training —— Refactoring from Anemic Domain Model Towards a Rich One (overview)
    病毒查杀 clamav —— 资料合集 & windows上安装 & .net项目中引入
    docker for windows 收费
  • 原文地址:https://www.cnblogs.com/xiuciedward/p/3198108.html
Copyright © 2020-2023  润新知