zoukankan      html  css  js  c++  java
  • 拖动调整显示框的显示区域大小

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>例子</title>
    <style>
    ul,li{margin:0;padding:0;}
    body{font:14px/1.5 Arial;color:#666;}
    #box{position:relative;600px;height:400px;border:2px solid #000;margin:10px auto;overflow:hidden;}
    #box ul{list-style-position:inside;margin:10px;}
    #top,#bottom{color:#FFF;height:200px;overflow:hidden;}
    #top{background:green;}
    #bottom{background:blue;}
    #line{position:absolute;top:50%;100%;height:4px;overflow:hidden;margin-top:-2px;background:red;cursor:n-resize;}
    </style>
    <script>
    function $(id) {
    return document.getElementById(id)
    }
    window.onload = function() {
    var oBox = $("box"), oTop = $("top"), oBottom = $("bottom"), oLine = $("line");
    oLine.onmousedown = function(e) {
    var disY = (e || event).clientY;
    oLine.top = oLine.offsetTop;
    document.onmousemove = function(e) {
    var iT = oLine.top + ((e || event).clientY - disY);
    var maxT = oBox.clientHeight - oLine.offsetHeight;
    oLine.style.margin = 0;
    iT < 0 && (iT = 0);
    iT > maxT && (iT = maxT);
    oLine.style.top = oTop.style.height = iT + "px";
    oBottom.style.height = oBox.clientHeight - iT + "px";
    return false
    };
    document.onmouseup = function() {
    document.onmousemove = null;
    document.onmouseup = null;
    oLine.releaseCapture && oLine.releaseCapture()
    };
    oLine.setCapture && oLine.setCapture();
    return false
    };
    };
    </script>
    </head>
    <body>
    <b>上下拖动红条改变显示区域高度</b>
    <div id="box">
    <div id="top">
    <ul>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    <li>西安一大厦发生爆炸7人遇难31人受伤</li>
    </ul>
    </div>
    <div id="bottom">
    <ul>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    <li>京沪高铁因质量问题被召回动车拟16日恢复运营</li>
    </ul>
    </div>
    <div id="line"></div>
    </div>
    </body>
    </html>
  • 相关阅读:
    pacx & zr(yet)
    FileInputStream RandomAccessFile FileChannel 与 MappedByteBuffer (yet)
    结合自定义注解的 spring 动态注入
    redis事务与管道区别
    jdk动态代理与cglib优势劣势以及jdk动态代理为什么要interface
    maven scope属性值设置含义
    xc (yet)
    单链表 环
    适配器模式,将老接口的数据给新接口用
    移动硬盘无法拷贝大于4G的文件
  • 原文地址:https://www.cnblogs.com/dream0530/p/5946584.html
Copyright © 2011-2022 走看看