°³Ã¼ÀÇ offsetTop°ú offsetLeft ¼Ó¼ºµéÀ» ÁöÁ¤ÇÑ ¿ë±â°³Ã¼ÀÇ ÂüÁ¶¸¦ ¹ÝȯÇÑ´Ù.
ÀÌ ¼Ó¼ºÀº ÀбâÀü¿ëÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.
´ëºÎºÐÀÇ °æ¿ì offsetParent ¼Ó¼ºÀº body °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.
°³Ã¼ | script | HTML | ±Ô°Ý | IE |
---|
offsetHeight offsetWidth offsetLeft offsetTop offsetParent
¾Õ °³Ã¼ | tddivObj °³Ã¼ |
µÞ °³Ã¼ |
<HTML> <HEAD> <SCRIPT> function showPosition(job){ if (job==1) obj=document.all.tableObj; else if (job==2) obj=document.all.tdObj; else if (job==3) obj=document.all.tddivObj; str='°³Ã¼ obj : '+obj.nodeName+' id='+obj.id+'<BR>'; str+='¿ë±â °³Ã¼ : obj.offsetParent.tagName='+obj.offsetParent.tagName+', obj.parentElement.id='+obj.parentElement.id+'<BR>'; str+='obj.offsetLeft='+obj.offsetLeft+'<BR>'; str+='obj.offsetTop='+obj.offsetTop+'<BR>'; str+='obj.offsetHeight='+obj.offsetHeight+'<BR>'; str+='obj.offsetWidth='+obj.offsetWidth+'<BR>'; showA.innerHTML=str; } </SCRIPT> <STYLE> button{width:150} </STYLE> </HEAD> <BODY id="bodyObj" onload="showPosition(1)"> <DIV id="divObj" style="text-align:right;border:solid 1 blue;padding:10"> <TABLE id="tableObj" border=1 cellpadding=5 width=400> <TR id="trObj"> <TD>¾Õ °³Ã¼</TD> <TD id="tdObj" style="background-color:ffffaa"><DIV id="tddivObj" style="background-color:ffaaff;width:200">tddivObj °³Ã¼</DIV></TD> <TD>µÞ °³Ã¼</TD> </TR> </TABLE> </DIV> <BUTTON onclick="divObj.style.textAlign='left';showPosition(1)">Å×ÀÌºí ¿ÞÂÊÀ¸·Î</BUTTON> <BUTTON onclick="divObj.style.textAlign='center';showPosition(1)">Å×À̺í Áß¾ÓÀ¸·Î</BUTTON> <BUTTON onclick="divObj.style.textAlign='right';showPosition(1)">Å×ÀÌºí ¿À¸¥ÂÊÀ¸·Î</BUTTON><BR> <BUTTON onclick="tdObj.style.textAlign='left';showPosition(2)">TD ¿ÞÂÊÀ¸·Î</BUTTON> <BUTTON onclick="tdObj.style.textAlign='center';showPosition(2)">TD Áß¾ÓÀ¸·Î</BUTTON> <BUTTON onclick="tdObj.style.textAlign='right';showPosition(2)">TD ¿À¸¥ÂÊÀ¸·Î</BUTTON><BR> <BUTTON onclick="tddivObj.style.textAlign='left';showPosition(3)">TD DIV ¿ÞÂÊÀ¸·Î</BUTTON> <BUTTON onclick="tddivObj.style.textAlign='center';showPosition(3)">TD DIV Áß¾ÓÀ¸·Î</BUTTON> <BUTTON onclick="tddivObj.style.textAlign='right';showPosition(3)">TD DIV ¿À¸¥ÂÊÀ¸·Î</BUTTON><BR> <DIV id=showA></DIV> </BODY> </HTML>