DIV 层覆盖问题?
<style type="text/css">
#aa{
width:200px;
height:200px;
top:200px;
left:200px;
background:#CCC;
position:absolute;
z-index:0;
display:block;
}
#aa p{
cursor:pointer;
background:#999;
margin-top:0;
}
#yy{
width:200px;
height:200px;
top:200px;
left:200px;
background:#CCC;
position:absolute;
z-index:0;
display:block;
}
#yy p{
cursor:pointer;
background:#999;
margin-top:0;
}
</style>
<script type="text/javascript">
function $(id){ return document.getElementById(id);}
var M = null,X,Y;
function m(id){
M = $(id);
M.style.zIndex = "1";
X = parseInt(M.offsetLeft) - event.x;
Y = parseInt(M.offsetTop) - event.y;
}
document.onmousemove = function (){
if(M){
if(X + event.x > 800 && Y + event.y > 300 ){
M.style.left = 800;
M.style.top = 300;
}else if(X + event.x > 800){
M.style.left = 800;
M.style.top = Y + event.y;
}else if(Y + event.y > 300){
M.style.left = X + event.x;
M.style.top = 300;
}else{
M.style.left = X + event.x;
M.style.top = Y + event.y;
}
event.returnValue = false;
}
}
document.onmouseup = function (){M = null;}
</script>
</head>
<body background="wallpaper.jpg">
<div id="aa">
<p onmousedown="m('aa')">xx</p>
</div>
<div id="yy">
<p onmousedown="m('yy')">yy</p>
</div>
</body>
这是代码,两个DIV 拖动xx到 yy上面把yy 覆盖 点yy 覆盖 xx 怎么做?
#aa{
width:200px;
height:200px;
top:200px;
left:200px;
background:#CCC;
position:absolute;
z-index:0;
display:block;
}
#aa p{
cursor:pointer;
background:#999;
margin-top:0;
}
#yy{
width:200px;
height:200px;
top:200px;
left:200px;
background:#CCC;
position:absolute;
z-index:0;
display:block;
}
#yy p{
cursor:pointer;
background:#999;
margin-top:0;
}
</style>
<script type="text/javascript">
function $(id){ return document.getElementById(id);}
var M = null,X,Y;
function m(id){
M = $(id);
M.style.zIndex = "1";
X = parseInt(M.offsetLeft) - event.x;
Y = parseInt(M.offsetTop) - event.y;
}
document.onmousemove = function (){
if(M){
if(X + event.x > 800 && Y + event.y > 300 ){
M.style.left = 800;
M.style.top = 300;
}else if(X + event.x > 800){
M.style.left = 800;
M.style.top = Y + event.y;
}else if(Y + event.y > 300){
M.style.left = X + event.x;
M.style.top = 300;
}else{
M.style.left = X + event.x;
M.style.top = Y + event.y;
}
event.returnValue = false;
}
}
document.onmouseup = function (){M = null;}
</script>
</head>
<body background="wallpaper.jpg">
<div id="aa">
<p onmousedown="m('aa')">xx</p>
</div>
<div id="yy">
<p onmousedown="m('yy')">yy</p>
</div>
</body>
这是代码,两个DIV 拖动xx到 yy上面把yy 覆盖 点yy 覆盖 xx 怎么做?
...全文
相关推荐
IE6下div层被select控件遮住的问题解决方法
IE6下层被select控件遮住的问题想必大家在布局过程中都有遇到过吧,其实解决方法很简单就是在层里套个iframe,具体实现如下,感兴趣的朋友可以参考下,希望对大家有所帮助
iFrame的妙用作为弹出层铺底覆盖
弹出的DIV没法遮住select,这就要使用到iframe,下面有个不错的示例,利用iframe作为弹出层铺底覆盖、跨域写入cookie
让div浮动在select之上的完美解决方案!多浏览器兼容
让div浮动在select之上的完美解决方案!多浏览器兼容
脚本控制三行三列自适应高度DIV布局
脚本控制三行三列自适应高度DIV布局
关于页面嵌入swf覆盖div层的问题的解决方法
主要介绍了关于页面嵌入swf覆盖div层的问题的解决方法,需要的朋友可以参考下


