| ·¹À̾î Áß¾Ó¿¡ À§Ä¡ ½Ã۱â | Go to UP |
ÆäÀÌÁöÀÇ Áß¾Ó¿¡ À§Ä¡ ½Ãų¶§´Â nn4´Â window.innerWidth, window.innerHeight ·Î ÆäÀÌÁöÀÇ Å©±â¸¦ ¾Ë ¼ö ÀÖ½À´Ï´Ù. À̰ÍÀº °¡º¯ÀûÀ¸·Î º¯È´Â °ÍÀÔ´Ï´Ù. Áï, document°¡ ÀÖ´Â º¸ÀÌ´Â ÆäÀÌÁö¸¦ ¸»ÇÕ´Ï´Ù. À̰Ͱú ´ëÀÀÇÏ´Â ie4ÀÇ °ÍÀº document.body.clientWidth, document.body.clientHeight ¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ie4¿Í nn4ÀÇ À̰͵éÀº ÆäÀÌÁö°¡ ÇÑ ÆäÀÌÁö¸¦ ³ÑÁö ¾ÊÀ» ¶§ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿À·ÎÁö ÇÑ ÆäÀÌÁö¿¡¼ÀÇ Å©±âÀÔ´Ï´Ù.
ÆäÀÌÁöÀÇ ³»¿ëÀÌ ¸¹¾Æ¼ ÇÑ ÆäÀÌÁö¸¦ ³Ñ¾î À̵¿¸·´ë°¡ »ý±â¸é À§ÀÇ ³ôÀ̷δ ´Ã¾î³ ÆäÀÌÁö¿¡¼ Áß¾Ó¿¡ À§Ä¡½ÃŰ´Â °ÍÀÌ ¾ÈµË´Ï´Ù. ÀÌ ¶§, nn4´Â document.width, document.height¸¦ »ç¿ëÇÒ ¼ö ÀÖ°í, ie4´Â document.body.scrollWidth, document.body.scrollHeight ¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. (ie4ÀÇ scrollÀº Á¤È®È÷ Áß¾Ó¿¡ À§Ä¡Çϱâ´Â ¾ÆÁ÷±îÁö ¸ð¸£°Ú½À´Ï´Ù.)
·¹À̾ ÀÚ½ÅÀÌ ·¹À̾ °¡Áö°í ÀÖÀ» ¶§, °¡Áö°í ÀÖ´Â ·¹À̾ ÀÚ½ÅÀÇ Áß¾Ó¿¡ À§Ä¡ ½ÃÄÑ¾ß º¸±â°¡ ÁÁÀ» ¶§°¡ ÀÖ½À´Ï´Ù. »óÀ§ÀÇ ·¹À̾îÀÇ Å©±â¸¦ ¾Ë¼ö ÀÖ´Â ¹æ¹ýÀº nn4¿¡¼´Â ·¹À̾îÀÇ document.height, document.width·Î ie4´Â ·¹À̾îÀÇ clientWidth, clientHeight·Î ¾Ë ¼ö ÀÖ½À´Ï´Ù.
clientWidth¿Í offsetWidthÀÇ Â÷ÀÌÁ¡Àº ·¹À̾ border°¡ ÀÖÀ» °æ¿ì offset´Â border¸¦ Æ÷ÇÔÇÑ Å©±âÀ̰í client´Â border¸¦ »«Å©±âÀÔ´Ï´Ù. 300x300 Å©±âÀÇ ·¹À̾ border°¡ 2¶ó¸é offset´Â 300À̰í client´Â 296ÀÌ µË´Ï´Ù. ¾çÂÊ borderÀÇ Å©±â¸¦ »« Å©±âÀÔ´Ï´Ù. ±×·¡¼, µÑ ´Ù ·¹ÀÌ¾î ¾ÈÀÇ ·¹À̾ Áß¾Ó¿¡ À§Ä¡½Ãų ¶§, »ç¿ëÇÒ ¼ö ÀÖÁö¸¸, border°¡ ÀÖ´Â ·¹À̾î¾È¿¡¼ Á¤¿ÇÒ ¶§´Â offset¸¦ »ç¿ëÇØ¾ß border °ª ¸¸ÅÀÇ Â÷À̰¡ ³ªÁö ¾Ê½À´Ï´Ù. borderµµ ·¹À̾îÀÇ ºÎºÐÀÌÁö¸¸ ·¹ÀÌ¾î ¾È¿¡¼ÀÇ ÁÂÇ¥´Â border´Â ÇØ´çÇÏÁö ¾Ê½À´Ï´Ù. border¹Ù·Î ¾ÈÂÊÀÌ 0px ÀÔ´Ï´Ù.
<style>
#D1 { position:absolute; width:400; height:400;
border-width:1; border-color:blue; border-style:solid;
}
#S1 { position:absolute; top:0; width:200; height:200;
border-width:1; border-color:yellow; border-style:solid;
}
</style>
function positionCenter(layer, upWidth, upHeight) {
if (n4) {
layer.left = (upWidth - layer.document.width)/2;
layer.top = (upHeight - layer.document.height)/2
}
else if (e4) {
layer.style.left = (upWidth - layer.offsetWidth)/2
layer.style.top = (upHeight - layer.offsetHeight)/2
}
}
if(n4) {
positionCenter(document.D1, window.innerWidth, window.innerHeight);
positionCenter(document.D1.document.S1, document.D1.document.width, document.D1.document.height);
}
if(e4) {
positionCenter(document.all.D1, document.body.clientWidth, document.body.clientHeight);
positionCenter(document.all.S1, document.all.D1.clientWidth, document.all.D1.clientHeight);
}
<div id=D1>
<table width=398 height=398><tr><td> </td></tr></table>
<div id=S1>
<table width=198 height=198><tr><td> </td></tr></table>
</div>
</div>