html 可以拖动多个div
来源:互联网 发布:unity3d手游开发教程 编辑:程序博客网 时间:2024/05/22 17:06
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#main div{position:absolute;width:220px;height:150px;border:1px solid #999;}
</style>
<script type="text/javascript">
var a;
document.onmouseup=function(){
if(!a)return;
document.all?a.releaseCapture():window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
a="";
};
document.onmousemove=function (d){
if(!a) return;
if(!d) d=event;
a.style.left=(d.clientX-b)+"px";a.style.top=(d.clientY-c)+"px";
};
function move(o,e){
a=o;
document.all?a.setCapture():window.captureEvents(Event.MOUSEMOVE);
b=e.clientX-parseInt(a.style.left);
c=e.clientY-parseInt(a.style.top);
o.style.zIndex=getMaxIndex()+1;
}
function $(id){return document.getElementById(id);}
function getMaxIndex(){
var index=0;
var ds=$('main').getElementsByTagName('div');
var l=$('main').getElementsByTagName('div').length;
for (i=0;i<l;i++)
{
if (ds[i].style.zIndex>index) index=ds[i].style.zIndex;
}
return index;
}
</script>
</head>
<body>
<div id="main">
<div style="left:100px;top:100px;background:#fc9;" onmousedown="move(this,event)">1</div>
<div style="left:400px;top:100px;background:#9cf;" onmousedown="move(this,event)">2</div>
<div style="left:700px;top:100px;background:#f9c;" onmousedown="move(this,event)">3</div>
<div style="left:100px;top:300px;background:#9fc;" onmousedown="move(this,event)">4</div>
<div style="left:400px;top:300px;background:#c9f;" onmousedown="move(this,event)">5</div>
<div style="left:700px;top:300px;background:#cf9;" onmousedown="move(this,event)">6</div>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#main div{position:absolute;width:220px;height:150px;border:1px solid #999;}
</style>
<script type="text/javascript">
var a;
document.onmouseup=function(){
if(!a)return;
document.all?a.releaseCapture():window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
a="";
};
document.onmousemove=function (d){
if(!a) return;
if(!d) d=event;
a.style.left=(d.clientX-b)+"px";a.style.top=(d.clientY-c)+"px";
};
function move(o,e){
a=o;
document.all?a.setCapture():window.captureEvents(Event.MOUSEMOVE);
b=e.clientX-parseInt(a.style.left);
c=e.clientY-parseInt(a.style.top);
o.style.zIndex=getMaxIndex()+1;
}
function $(id){return document.getElementById(id);}
function getMaxIndex(){
var index=0;
var ds=$('main').getElementsByTagName('div');
var l=$('main').getElementsByTagName('div').length;
for (i=0;i<l;i++)
{
if (ds[i].style.zIndex>index) index=ds[i].style.zIndex;
}
return index;
}
</script>
</head>
<body>
<div id="main">
<div style="left:100px;top:100px;background:#fc9;" onmousedown="move(this,event)">1</div>
<div style="left:400px;top:100px;background:#9cf;" onmousedown="move(this,event)">2</div>
<div style="left:700px;top:100px;background:#f9c;" onmousedown="move(this,event)">3</div>
<div style="left:100px;top:300px;background:#9fc;" onmousedown="move(this,event)">4</div>
<div style="left:400px;top:300px;background:#c9f;" onmousedown="move(this,event)">5</div>
<div style="left:700px;top:300px;background:#cf9;" onmousedown="move(this,event)">6</div>
</div>
</body>
</html>
0 0
- html 可以拖动多个div
- 可以拖动的DIV
- 可以拖动的DIV
- 可以拖动的div
- 基于jQuery(原生也可以)实现HTML元素拖动(自制窗口拖动,以及多个窗口拖动并且互不干扰)源代码
- jquery 可以拖动div层
- HTML 可拖动div标签
- 可以拖动的table--html
- (html/javascript)可以用鼠标自由拖动的div(收藏)
- (html/javascript)可以用鼠标自由拖动的div(收藏)
- html 并列多个DIV
- 可以拖动的div(一)
- 可以拖动的DIV(二)
- jQuery实现可以拖动的div
- 实现可以拖动的div层
- 创建鼠标可以拖动的DIV
- HTML DIV 层拖动简单实现
- 可以拖动排版可以关闭的DIV层
- 导入android工程后出现The resource is not on the build path of a java project
- 证书安装
- java 字节流与字符流的区别
- px、dp和sp,这些单位有什么区别?
- ARM GNU 汇编宏定义
- html 可以拖动多个div
- 创意摄影:月球变唯美篮球
- 供求关系信息自动匹配即产品信息自动匹配
- 在jsp中使用xheditor
- 矩形--无参
- UIKit框架支持8种风格键盘。
- BIRT 在IE10浏览器显示不全解决方案
- VMware9.0虚拟机Ubuntu使用PC的USB转串口
- 初学WebSocket