如何定义一个DIV在另一个DIV左顶点的相对位置[可以任意更改窗口大小位置不变]。高手指点
如何定义一个DIV在另一个DIV左顶点的相对位置[可以任意更改窗口大小位置不变]。高手指点
------解决方案--------------------这个div是另一个div的子节点 
 position:absolute;top:xx;left:xx 
 拖动的时候只改变width/height
------解决方案-------------------- <HTML>  
  <HEAD>  
  <style>  
 .divstyle {width:150px; height:300px; border:1px solid green; background-color:#EEEEEE;} 
  </style>  
  <script>  
 function init(){ 
   var div1=document.getElementById( 'div1 '); 
   var div2=document.getElementById( 'div2 '); 
   div2.style.left=div1.offsetLeft+15; //div2相对于div1的左上角x轴偏移量 
   div2.style.top=div1.offsetTop+15;   //div2相对于div1的左上角y轴偏移量 
 } 
  </script>  
  </head>  
  <body onload= "init() ">  
  <div id= "div1 " class= "divstyle " style= "position:absolute; left:50px; top:50px; z-index:1; "> 层一 </div>  
  <div id= "div2 " class= "divstyle " style= "position:relative; z-index:2; "> 层二 </div>  
  </BODY>  
  </HTML>