| CSS·Î À̹ÌÁö ¹Ù²ÞÈ¿°ú ³»±â | Go to UP |
À̰ÍÀ» Àß ÀÌ¿ëÇϸé À̹ÌÁö¸¦ Àû°Ô »ç¿ëÇÒ ¼ö°¡ ÀÖ½À´Ï´Ù. ´ç¿¬È÷ ¼Óµµ°¡ »¡¶ó Áý´Ï´Ù.
<style>
(0) #rollver { position:relative; }
(1) #backColor { position:absolute; left:100px; top:200px; width:500; visibility:hidden;
(2) background-color:red; layer-background-color:red; clip:rect(0,500,10,0);
}
(3) #IMG { position:absolute; left:100px; top:200px; clip:rect(0, 500, 10, 0);
}
</style>
<div id=backColor></div>
<div id=IMG><a href="#" onMouseOver="over(false, 0, 100)" onMouseOut="over(true)"
><img src="../images/gb1.gif" border="0" width=100 height=10
></a></div>
¿©±â¼ ¹Ù²Ü »ö±ò·Î "backColor"¶ó´Â À̸§ÀÇ div ºí·Ï ÅÃÀ» »ç¿ë Çß½À´Ï´Ù. ÀÌ ºí·ÏÀÇ ¹ÙÅÁ»öÀº »¡°»öÀÔ´Ï´Ù. ÀÌ »ö±òÀÌ
Åõ¸íÀ̹ÌÁö ¹Ø¿¡ ÀÖ½À´Ï´Ù. Åõ¸íÀ̹ÌÁö ¹ØÀÇ »öÀ» ¹Ù²Ù¸é Åõ¸íÀ̹ÌÁö ÁßÀÇ ÀϺΰ¡ ±× »ö±òÀÌ ³ª¿É´Ï´Ù. ±×·¯¹Ç·Î,
¹Ù²Ü »ö±òÀ» À̹ÌÁö°¡ À§¿¡ ¿Ã ¼ö ÀÖ°Ô ÆäÀÌÁö¿¡¼ À̹ÌÁöº¸´Ù ¸ÕÀú Ãâ·ÂµÇ¾î¾ß ÇÕ´Ï´Ù. ³ªÁß¿¡ Ãâ·ÂµÇ´Â
position element°¡ ¸ÕÀú Ãâ·ÂµÈ position element À§¿¡ ¿É´Ï´Ù.
ÁÖ¼® (1)¹ø ÁÙÀÇ visibility:hidden´Â ¸¶¿ì½º°¡ À̹ÌÁö À§¿¡ °¬À» ¶§ »ç¿ëÇÒ °ÍÀ̹ǷΠóÀ½¿¡´Â º¸ÀÌÁö ¾Ê°Ô ÇÕ´Ï´Ù.
width:500;Àº IE4ÀÇ °æ¿ì À̰ÍÀ¸·Î ³ÐÀ̸¦ ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é ÇÑ ÁÙ ´Ù »ö±òÀ» ÀÔÈü´Ï´Ù. clip·Îµµ ÁöÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.
ÁÖ¼® (2)¹ø ÁÙÀÇ layer-background-color:red;´Â NN4ÀÇ CSS layer ¹ÙÅÁ»ö bugÀÔ´Ï´Ù. ÁöÁ¤µÈ Å©±â ¸¸Å
¹ÙÅÁ»öÀ» ÀÔÈü´Ï´Ù. background-color:red;´Â ³»¿ë¹°ÀÌ Àִ¸¸Å ¸¸ »ö±òÀ» ÀÔÈü´Ï´Ù. NN4 CSS Layer¿¡¼´Â
layer-background-color:red;À» »ç¿ë Çϼ¼¿ä. À̰ÍÀº NN¿¡¼ ¸¸ Áö¿øÇÕ´Ï´Ù.
NN4, IE4¿¡¼ µÑ ´Ù ¸¶Âú°¡Áö ÀÌÁö¸¸, ºê¶ó¿ìÀú°¡ Áö¿øÇÏÁö ¾Ê´Â Attribute´Â ±×³É ¹«½Ã ÇÕ´Ï´Ù. ¿¡·¯°¡ ³ªÁö ¾Ê½À´Ï´Ù. µû¶ó¼, background-color:red; layer-background-color:red; ÀÌ·¸°Ô µÑ ´Ù ³Ö¾îÁÖ¸é IE4´Â µÚÀÇ °ÍÀ» ¹«½ÃÇϰí NN4Àº µÎ¹ø ¼³Á¤ÇϹǷÎ, µÚ¿¡ ¼³Á¤ÇÑ °ÍÀÌ ÁöÁ¤µË´Ï´Ù.
ÁÖ¼® (2)¹øÀÇ clip:rect(0,500,10,0)´Â Å©±â°¡ 100x10ÀÎ À̹ÌÁö°¡ 5°³°¡ ÀÖÀ¸¹Ç·Î ÀÌ·¸°Ô ÁöÁ¤À» ÇÕ´Ï´Ù.
clip:rect(top, right, bottom, left)ÀÔ´Ï´Ù.
ÁÖ¼® (0)¹øÀº ÆäÀÌÁö ¾Æ¹«µ¥³ª Æí¸®ÇÏ°Ô µÎ±âÀ§ÇØ µÎ layer¸¦ position:reletive; À» °¡Áø layer·Î °¨½Õ½À´Ï´Ù.
function verChack() {
NN4 = (document.layers) ? true : false;
IE4 = (document.all) ? true : false;
DHTML = ( NN4 || IE4 ) ? true : false;
}
¿©±â¼ »ç¿ëÀÚÀÇ ºê¶ó¿ìÀú¸¦ ±¸ºÐÇÕ´Ï´Ù. layers´Â NN4¿¡¼ Áö¿øÇÏ´Â ObjectÀÔ´Ï´Ù. allÀº IE4¿¡¼ Áö¿øÇÕ´Ï´Ù.
À̰ÍÀÌ if ¹® ¾È¿¡¼´Â Áö¿øÇϸé TRUE¸¦ ±×·¸Áö ¾ÊÀ¸¸é FALSE¸¦ ¹ÝȯÇÕ´Ï´Ù. µÑ ´Ù Áö¿øÇÏÁö ¾ÊÀ¸¸é DHTMLÀ»
Áö¿øÇÏÁö ¾Ê´Â ºê¶ó¿ìÀú NN3, IE3.02 ÀÌÇÏ·Î º¸°í DHTML ¿ÜºÎ º¯¼ö¿¡ ÀúÀåÇÕ´Ï´Ù.
<div id=IMG> <a href="#" onMouseOver="over(false, 100, 200)" onMouseOut="over(true)"> <!-- (1) --> <img src="../images/gb1.gif" border=0> </a> </div>(1)¹ø ÁÙÀÇ onMouseOver = "over(false, 100, 200)"¿¡¼ false´Â mouseover°ú mouseout¸¦ ±¸ºÐÇϱâ À§ÇÑ °ÍÀÌ°í µÚÀÇ 100, 200Àº À̹ÌÁö layerÀÇ ¹ØÀÇ layerÀÇ ¹ÙÅÁ»öÀ» À̹ÌÁö À§Ä¡¿Í °°Àº ¸¸Å ¸¸ ¹Ù²Ù±â À§Çؼ À̹ÌÁöÀÇ Å©±â¿Í °°ÀÌ ÁöÁ¤ÇÕ´Ï´Ù. onMouseOut = "over(true)"´Â ¸¶¿ì½º°¡ À̹ÌÁö¸¦ ºüÁ® ³ª°¬À» ¶§, ¿ø·¡ÀÇ À̹ÌÁö »öÀ¸·Î µÎ±âÀ§ÇØ ¹ØÀÇ layer¸¦ º¸ÀÌÁö ¾Ê°Ô ÇÏ´Â °ÍÀÔ´Ï´Ù.
function over(flag, left, right) {
(1) if ( !DHTML ) return;
(2) if (NN4) var backColorLayer = document.rollver.document.backColor;
(3) if (IE4) var backColorLayer = document.all.backColor.style;
(4) if ( flag ) { backColorLayer.visibility = "hidden"; return; }
if ( NN4 ) {
(5) backColorLayer.clip.left = left;
(6) backColorLayer.clip.right = right;
}
(7) if ( IE4 ) backColorLayer.clip = "rect("+clipTop+" "+right+" "+clipBottom+" "+left+")";
(8) backColorLayer.visibility = "visible";
}
(9) clipTop = 0; clipBottom = 10;
(1)Àº NN4, IE4°¡ ¾Æ´Ñ ºê¶ó¿ìÀú´Â À§¿¡¼ DHTML¿¡ nullÀÌ ÁöÁ¤µÇ¾î ÀÖ½À´Ï´Ù. µû¶ó¼, if (!DHTML)Àº ÂüÀÔ´Ï´Ù.
¿©±â¼ ÇÔ¼ö¸¦ ºüÁ® ³ª°©´Ï´Ù. (2), (3)¹øÀº NN4¿Í IE4¿¡¼ Position element¸¦ »ç¿ëÇÏ´Â ¹æ½ÄÀÌ ´Ù¸¨´Ï´Ù.
NN4´Â layer¶ó´Â »õ·ÎÀÌ Ãß°¡µÈ ObjectÀÔ´Ï´Ù. images¿Í °°½À´Ï´Ù. ±×¸®°í layer ¼ÓÀÇ ¸ðµç °ÍÀº layerÀÇ documentÀÔ´Ï´Ù.
IE4´Â ÆäÀÌÁö¿¡ Ãâ·ÂµÈ ¸ðµç styleÀ» °¡Áø ÅÃÀº "all" Object¿¡ ¼ÓÇÕ´Ï´Ù. ±×·¡¼, ¾Õ¿¡ allÀ» ³Ö¾îÁà¾ß ÇÕ´Ï´Ù. ±×¸®°í, ÅÃÀÌ styleÀ» °¡Áö°í ÀÖÀ» ¶§, °¢ style Property´Â "style"À̶ó´Â Object¿¡ Æ÷ÇÔ µË´Ï´Ù. ±×·¡¼ °¢ style property¸¦ ÂüÁ¶ÇÒ ¶§, style property¾Õ¿¡ style¸¦ ³Ö¾îÁà¾ß ÇÕ´Ï´Ù. ±×¸®°í, NN4¿Í´Â ´Ù¸£°Ô layer¼ÓÀÇ layerµµ °°Àº °èÃþÀÔ´Ï´Ù.
(4)´Â ¸¶¿ì½º°¡ À̹ÌÁö¸¦ ºüÁ®³ª°¥ ¶§, flag °ªÀ¸·Î true¸¦ ÁÝ´Ï´Ù. ´Ù½Ã ¹ØÀÇ ¹ÙÅÁ»öÀ» º¸ÀÌÁö ¾Ê°Ô ÇÕ´Ï´Ù. ¿ø·¡ÀÇ Åõ¸í À̹ÌÁöÀÇ »öÀ¸·Î µ¹·Á ³õ½À´Ï´Ù. ±×¸®°í, ÇÒ ÀÏÀÌ ¾øÀ¸¹Ç·Î, ºüÁ® ³ª°©´Ï´Ù.
(5), (6), (7)¿¡¼ CLIPÀº block elementÀÇ Å©±â¸¦ ÀÚ¸¦ ¶§ »ç¿ëÇÕ´Ï´Ù. cilp.top, clip.right, clip.bottom, clip.left 4°¡Áö°¡ ÀÖ½À´Ï´Ù.
ÀÌ clipµµ NN4¿Í IE4°¡ »ç¿ëÇÏ´Â ¹æ¹ýÀÌ ´Ù¸¨´Ï´Ù. NN4¿¡¼´Â 4°³ Áß ÇÑ °³³ª µÎ°³ ÀÌ»óÀ» ÁöÁ¤Çϸé ÁöÁ¤µÈ ºÎºÐ¿¡
Å©±â¸¦ ¹Ù²ß´Ï´Ù. ¹Ý¸é¿¡, IE4¿¡¼´Â 4°¡Áö ¸ðµÎ °°ÀÌ »ç¿ëÇØ¾ß Çϰí, ÇϳªÀÇ ¹®ÀÚ¿·Î »ç¿ë ÇÕ´Ï´Ù. Áï, style¿¡¼
clip:rect(0,500,10,0); À» ÁöÁ¤Çϸé IE4´Â
document.all.element.style.clip="rect(toppx rightpx bottompx leftpx)"
·Î ´Ü¼øÇÑ ¹®ÀÚ¿ÀÔ´Ï´Ù. ´ÜÀ§ px´Â ÀÚµ¿À¸·Î ºÙ½À´Ï´Ù.
(8)Àº ¹ØÀÇ layer¸¦ º¸ÀÌ°Ô ÇÕ´Ï´Ù. À§¿¡¼ Å©±â´Â clip·Î ÁöÁ¤À» Çß½À´Ï´Ù. clipÇÑ °ÍÀ» º¸ÀÌ°Ô ÇÕ´Ï´Ù.
(9)´Â ¿©±â¼ À̹ÌÁöÀÇ top°ú bottomÀº ÀÏÁ¤ÇÑ Å©±â 100, 10ÀÔ´Ï´Ù. µû¶ó¼, NN4¿¡¼´Â left¿Í right¸¸ ÀÖÀ¸¸é µÇÁö¸¸, (9)´Â IE4¸¦ À§Çؼ ÀÔ´Ï´Ù. IE4´Â 4°³ÀÇ clip°¡ °°ÀÌ »ç¿ëÀ» ÇÕ´Ï´Ù.
<html>
<head>
<style>
#rollver { position:relative; };
#backColor { position:absolute; left:10px; top:20px; width:500; visibility:hidden;
background-color:red; layer-background-color:red; width:500; clip:rect(0,500,10,0);
}
#IMG { position:absolute; left:10px; top:20px; width:500; clip:rect(0, 500, 10, 0);
}
</style>
<SCRIPT LANGUAGE="JAVASCRIPT">
function verChack() {
NN4 = (document.layers) ? true : false;
IE4 = (document.all) ? true : false;
DHTML = ( NN4 || IE4 ) ? true : false;
}
function over( flag, left, right) {
if ( !DHTML ) return;
if (NN4) var backColorLayer = document.rollver.document.backColor;
if (IE4) var backColorLayer = document.all.backColor.style;
if ( flag ) { backColorLayer.visibility = "hidden"; return; }
if ( NN4 ) {
backColorLayer.clip.left = left;
backColorLayer.clip.right = right;
}
if ( IE4 ) backColorLayer.clip = "rect("+clipTop+" "+right+" "+clipBottom+" "+left+")";
backColorLayer.visibility = "visible";
}
clipTop = 0; clipBottom = 10;
verChack();
</script>
</head>
<body>
<div id=rollver>
<div id=backColor></div>
<div id=IMG><a href="#" onMouseOver="over(false, 0, 100)" onMouseOut="over(true)"
><img src="../images/gb1.gif" border="0" alt="gif1"
></a><a href="#" onMouseOver="over(false, 100, 200)" onMouseOut="over(true)"
><img src="../images/gb2.gif" border="0" alt="gif2"
></a><a href="#" onMouseOver="over(false, 200, 300)" onMouseOut="over(true)"
><img src="../images/gb3.gif" border="0" alt="gif3"
></a><a href="#" onMouseOver="over(false, 300, 400)" onMouseOut="over(true)"
><img src="../images/gb4.gif" border="0" alt="gif4"
></a><a href="#" onMouseOver="over(false, 400, 500)" onMouseOut="over(true)"
><img src="../images/gb5.gif" border="0" alt="gif5"
></a></div>
</div>
</BODY>
</HTML>