<style type="text/css"> body { color:#FFFFFF; font-size: 12px; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } #a1 { display: none; position: absolute; left: 50px; top: 50px; z-index: 99; height: 200px; width: 200px; background: #0000FF; } #a2 { display: none; position: absolute; left: 300px; top: 200px; z-index: 100; height: 200; width: 200; background: #000000; filter:Alpha(opacity=60); opacity=0.6; } #a3 { display: none; position: absolute; z-index: 101; height: 200px; width: 200px; background: #FF0000; }</style> <script type="text/javascript"> //定义移动对象和移动坐标 var Mouse_Obj=null,_x,_y; //拖动对象函数(自动) document.onmousemove=function() { if(Mouse_Obj) { Mouse_Obj.style.left=_x+event.x; Mouse_Obj.style.top=_y+event.y; event.returnValue=false; } } //停止拖动函数(自动) document.onmouseup=function() { Mouse_Obj=null; } //确定被拖动对象函数 o为被拖动对象 function m(o) { Mouse_Obj=o; _x=parseInt(Mouse_Obj.style.left)-event.x; _y=parseInt(Mouse_Obj.style.top)-event.y; } </script> <div id="a1" onmousedown="m(this);" style="left: 50px;top: 50px;"><input type="button" value="关闭层1" onClick="document.getElementById('a1').style.display='none';"></div> <div id="a2" onmousedown="m(this)" style="left: 200px;top: 50px;"><input type="button" value="关闭层2" onClick="document.getElementById('a2').style.display='none';"></div> <div id="a3" onmousedown="m(this)" style="left: 100px;top: 100px;"><input type="button" value="关闭层3" onClick="document.getElementById('a3').style.display='none';"></div> <br> <input type="button" value="打开层1" onClick="document.getElementById ('a1').style.display='block';"> <input type="button" value="打开层2" onClick="document.getElementById ('a2').style.display='block';"> <input type="button" value="打开层3" onClick="document.getElementById ('a3').style.display='block';"> |