日期:2014-05-17  浏览次数:21025 次

关于div+css 层的拖动问题向高手磕头求教
小弟在网上找到一段代码,但实现不了自己想要的效果,特来请求高手帮忙^_^
网上原先弄来的代码浏览后显示了三个层dom0,dom1,dom2可以相互拖动。原代码是没有任何问题,
可我在dw中添加了一个新的层dom2222后,拖动效果就变样了,拖起来不是很顺畅。我想要实现的是不管我在dw中增加多少个层,多能象如出那样拖动,跪求高手帮忙。
代码如下:
<style>
body   {margin:0px;padding:0px;font-size:12px;text-align:center;}
body   >   div   {text-align:center;   margin-right:auto;   margin-left:auto;}  
.content{width:900px;}
.content   .left{
                float:left;
                width:20%;
                /*border:1px   solid   #FF0000;*/
                margin:3px;
}
.content   .center{float:left;border:1px   solid   #ffffff;margin:3px;width:57%}
.content   .right{float:right;width:20%;border:1px   solid   #ffffff;margin:3px}
.content   .right2{float:right;width:20%;border:1px   solid   #ffffff;margin:3px}
.mo{height:auto;border:1px   solid   #CCC;margin:3px;background:#FFF}
.mo   h1{background:#ECF9FF;height:18px;padding:3px;cursor:move}
.closediv{cursor:default;}
.minusspan{cursor:default;}
.mo   .nr{height:80px;border:1px   solid   #F3F3F3;margin:2px}
h1{margin:0px;padding:0px;text-align:left;font-size:12px}
.dragging   {
                FILTER:   progid:DXImageTransform.Microsoft.Alpha(opacity=60);   opacity:   0.6;   moz-opacity:   0.6
}
</style>
<script>
/*
ikaiser@163.com   2007-1-11   改动&#402;、添加拖动层时的虚线框&#8222;、添加拖动层时的半透明效果…、加入层折叠和关闭功能
具体的代码改动我已经在代码中标出
*/
var   dragobj={}
window.onerror=function(){return   false}
var   domid=12
function   on_ini(){
                String.prototype.inc=function(s){return   this.indexOf(s)> -1?true:false}
                var   agent=navigator.userAgent
                window.isOpr=agent.inc( "Opera ")
                window.isIE=agent.inc( "IE ")&&!isOpr
                window.isMoz=agent.inc( "Mozilla ")&&!isOpr&&!isIE
                if(isMoz){
                                Event.prototype.__defineGetter__( "x ",function(){return   this.clientX+2})
                                Event.prototype.__defineGetter__( "y ",function(){return   this.clientY+2})
                }
                basic_ini()
}
function   basic_ini(){
                window.$=function(obj){return   typeof(obj)== "string "?document.getElementById(obj):obj}
                window.oDel=function(obj){if($(obj)!=null){$(obj).parentNode.removeChild($(obj))}}
}
window.oDel=function(obj){if($(obj)!=null){$(obj).parentNode.removeChild($(obj))}}

window.onload=function(