zoukankan      html  css  js  c++  java
  • 可拖动大小div案例

    <!DOCTYPE html>    
    <html>    
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />    
    <title>drag div</title>   
    <style type="text/css">    
    <style type="text/css">     
    body{font:14px/1.5 Arial;color:#666;}    
    #box{position:relative;width:600px;height:400px;border:2px solid #000;margin:10px auto;overflow:hidden;}    
    #box ul{list-style-position:inside;margin:10px;}    
    #box div{position:absolute;width:100%;}    
    #top,#bottom{color:#FFF;height:100%;overflow:hidden;}    
    #bottom{<span style="color:#ff0000;BACKGROUND-COLOR: #3333ff">background-color:white;</span>top:50%}    
    #line{top:50%;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"), 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 = oBottom.style.top = iT + "px";    
    return false    
    };    
    document.onmouseup = function() {    
    document.onmousemove = null;    
    document.onmouseup = null;    
    oLine.releaseCapture && oLine.releaseCapture()    
    };    
    oLine.setCapture && oLine.setCapture();    
    return false    
    };    
    };    
    </script>  
    <div id="box">    
    <div id="top">  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    </div>    
    <div id="bottom">  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    <font color='black'>2</font></br>  
    </div>    
    <div id="line"></div>    
    </div>    
    </body>    
    </html>  
  • 相关阅读:
    素数
    Java日期时间使用(转)
    mysql中函数(转)
    java环境配置
    volley三种基本请求图片的方式与Lru的基本使用:正常的加载+含有Lru缓存的加载+Volley控件networkImageview的使用
    Volley的三种基本用法StringRequest的Get和post用法以及JsonObjectRequest
    DOM生成&解析
    Pull生成&解析
    HDU.2503 a/b + c/d (分式化简)
    HDU.2503 a/b + c/d (分式化简)
  • 原文地址:https://www.cnblogs.com/yudishow/p/4580771.html
Copyright © 2011-2022 走看看