zoukankan      html  css  js  c++  java
  • 进度条2

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>拖动条</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            .box1{
                 600px;
                height: 10px;
                background-color: red;
                margin: 300px auto;
                position: relative;
            }
            .box2{
                height: 30px;
                 40px;
                background-color: pink;
                position: absolute;
                left: 0;
                top: -10px;
            }
            .box1 span{
                 40px;
                height: 40px;
                position: absolute;
                background-color: yellow;
                left: -50px;
                top: -15px;
                text-align: center;
                line-height: 40px;
            }
            .box1 p{
                 40px;
                height: 40px;
                position: absolute;
                top: -15px;
                left: 600px;
                text-align: center;
                line-height: 40px;
            }
        </style>
        <script src="../public.js"></script>
    </head>
    <body>
    <div class="box1">
        <span id="txt"></span>
        <p>10</p>
        <div class="box2"></div>
    </div>
    </body>
    <script>
        var otxt=document.querySelector("#txt");
        var oBox1=document.querySelector(".box1");
        var oBox2=document.querySelector(".box2");
        addEvent(oBox2,"mousedown",hit)
        function hit(eve) {
            var e1=eve||window.event;
            var l=e1.clientX-oBox2.offsetLeft;
            addEvent(document,"mousemove",move)
            function move(eve) {
                var e2=eve||window.event;
                var x=e2.clientX-l;
    //            var x=e2.clientX-oBox1.offsetLeft-e1.offsetX;
                if(x<=0){
                    x=0;
                }
                else if(x>=560){
                    x=560
                }
                oBox2.style.left=x+"px"
                // 清除拖动 --- 防止鼠标已经弹起时还在拖动
                var a=(x/560*10).toFixed(1)
                otxt.innerHTML=a
    
                window.getSelection ? window.getSelection().removeAllRanges():document.selection.empty();
            }
            addEvent(document,"mouseup",up)
            function up() {
                removeEvent(document,"mousemove",move)
            }
    
        }
    </script>
    </html>
  • 相关阅读:
    ThreadLocal的分享
    remot debug
    小计-git
    入坑HttpServletRequest.getParameterMap
    基于线程池和连接池的Http请求
    spring,maven,dubbo配置
    springMVC,mybatis配置事务
    寻找数组的主元素问题的解法
    关于最大子序列和问题以及相关衍生问题的分析
    关于选择问题的一些思路.
  • 原文地址:https://www.cnblogs.com/hy96/p/11446209.html
Copyright © 2011-2022 走看看