類似QQ對話方塊上下部分可拖動程式碼

life66881發表於2015-03-18
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>類似QQ對話方塊上下部分可拖動程式碼-例子程式碼</title>
<style>
ul,li{margin:0;padding:0;}
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;}
#top{background:green;}
#bottom{background:skyblue;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>
</head>
<body>
<center>上下拖動紅條改變顯示區域高度</center>
<div id="box">
    <div id="top">
        <ul>
            <li><a href="/soft/3183.shtml" target="_blank">上面顯示的內容</a></li><li><a href="/soft/3279.shtml" target="_blank">上面顯示的內容</a></li><li><a 


href="/soft/2967.shtml" target="_blank">上面顯示的內容</a></li><li><a href="/soft/5047.shtml" target="_blank">上面顯示的內容</a></li><li><a href="/soft/1789.shtml" 


target="_blank">上面顯示的內容</a></li><li><a href="/soft/1786.shtml" target="_blank">上面顯示的內容</a></li><li><a href="/soft/3580.shtml" target="_blank">上面顯示的內容


</a></li><li><a href="/soft/3450.shtml" target="_blank">上面顯示的內容</a></li><li><a href="/soft/3454.shtml" target="_blank">上面顯示的內容</a></li><li><a 


href="/soft/2434.shtml" target="_blank">上面顯示的內容</a></li>
        </ul>
    </div>
    <div id="bottom">
        <ul>
            <li><a href="/soft/16003.shtml" target="_blank">下面顯示的內容</a></li><li><a href="/soft/16002.shtml" target="_blank">下面顯示的內容</a></li><li><a 


href="/soft/16001.shtml" target="_blank">下面顯示的內容</a></li><li><a href="/soft/16000.shtml" target="_blank">下面顯示的內容</a></li><li><a href="/soft/15999.shtml" 


target="_blank">下面顯示的內容</a></li><li><a href="/soft/15921.shtml" target="_blank">下面顯示的內容</a></li><li><a href="/soft/15867.shtml" target="_blank">下面顯示的內


容</a></li><li><a href="/soft/15866.shtml" target="_blank">下面顯示的內容</a></li><li><a href="/soft/15781.shtml" target="_blank">下面顯示的內容</a></li><li><a 


href="/soft/15780.shtml" target="_blank">下面顯示的內容</a></li>
        </ul>
    </div>
    <div id="line"></div>
</div>
<div><A href="http://www.999jiujiu.com/">http://www.999jiujiu.com/</A></div>
</body>
</html>

相關文章