这个div是另一个div的子节点
position:absolute;top:xx;left:xx
拖动的时候只改变width/height

解决方案 »

  1.   

    <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>
      

  2.   

    下面是常用的关于对象、事件触发的位置、高、宽的一些语句,你可以自己试试
    obj.clientLeft
    obj.clientTop
    obj.offsetLeft
    obj.offsetTop
    obj.scrollLeft
    obj.scrollTopobj.clientWidth
    obj.clientHeight
    obj.offsetWidth
    obj.offsetHeight
    obj.scrollWidth
    obj.scrollHeightevent.clientX
    event.clientY
    event.offsetX
    event.offsetY
    event.screenX
    event.screenYscreen.width
    screen.height
    screen.availHeight
    screen.availWidth