ìì ë§¥ë½ ìì 1
기본 ìì ë¶í° ììíì. ìì ë§¥ë½ì ë¿ë¦¬ìë ëê°ì DIV #1ê³¼ DIV #3ê° ìë¤. ë DIVë 모ë position ìì± ê°ì´ relativeë¡ ì§ì ëìì§ë§ z-index ìì± ê°ì ì§ì ëì§ ììë¤. DIV #1 ììë position ìì± ê°ì´ absoluteë¡ ì§ì ë DIV #2ê° ìê³ DIV #3 ììë position ìì± ê°ì´ absoluteê° ì§ì ë DIV #4ê° ìë¤. DIV #2ìã DIV #4 모ë z-index ìì± ê°ì ì§ì ëì§ ììë¤.
ì ì¼í ìì ë§¥ë½ì ë¿ë¦¬ ì리먼í¸ë¤. z-indexê° ìë ì리먼í¸ë¤ì HTML 문ììì ë±ì¥ ììëë¡ ìì¸ë¤.

DIV #2ì z-index ìì± ê°ì 0ëë autoê° ìë ìì ì ìë¡ ì§ì íë©´ ë¤ë¥¸ DIVë¤ ë³´ë¤ ìì ë ëë§ëë¤.

DIV #4ì z-index ìì± ê°ì DIV #2ì z-index ìì± ê°ë³´ë¤ í° ê°ì¼ë¡ ì§ì íë©´ DIV #4ë DIV #2ë³´ë¤ ìì ë ëë§ëë¤.

ë§ì§ë§ ìì ìì DIV #2ì DIV #4ë íì ê° ìëë¤. ìëíë©´ ëì ë¶ëª¨ê° ë¤ë¥´ê¸° ë문ì´ë¤. ê·¸ë¼ìë ë¶êµ¬íê³ DIV #2ì DIV #4ì ìì ìì를 z-index ìì± ê°ì ì§ì í¨ì¼ë¡ì¨ ë°ê¿ ì ììë¤. ìëíë©´ DIV #1ê³¼ DIV #3ì z-index ìì± ê°ì´ ì§ì ëì§ ììê³ ë°ë¼ì ìì ë§¥ë½ì ë§ë¤ì§ ìì기 ë문ì´ë¤. ë°ë¼ì DIV #2ì DIV #4ë ë ë¤ ë¿ë¦¬ ì리먼í¸ì ìì ë§¥ë½ì ìí´ìê³ , z-index ìì± ê°ì ë³ê²½íì¬ ìì ìì를 ë°ê¿ ì ìë¤.
ìì ë§¥ë½ì ì©ì´ë¡ ì¤ëª íìë©´ DIV #1ê³¼ DIV #3ì ë¿ë¦¬ ì리먼í¸ì ëíëìë¤. ì´ ìì ì DIVë¤ì ë¤ìê³¼ ê°ì ìì ë§¥ë½ ê³ì¸µ 구조를 ì´ë£¬ë¤.
- ë¿ë¦¬ ìì ë§¥ë½
- DIV #2 (z-index 1)
- DIV #4 (z-index 2)
ì°¸ê³ : DIV #1ê³¼ DIV #3ì í¬ëª íì§ ìë¤. í¬ëª ë를 1ë³´ë¤ ì ì ê°ì¼ë¡ ì§ì íê² ëë©´ ë´ë¶ì ì¼ë¡ ìì ë§¥ë½ì ë§ë ë¤ë걸 기ìµíì. ì´ê±´ ë§ì¹ z-index ê°ì ì¤ì í ê²ê³¼ ë¹ì·íë¤. ì´ ìì ë ë¶ëª¨ ì리먼í¸ë¤ì´ ìì ë§¥ë½ì íì±íì§ ìì ë ì´ë¤ ì¼ì´ ì¼ì´ëëì§ ë³´ì¬ì¤ë¤.
ìì
>HTML
<div id="div1">
<br /><span class="bold">DIV #1</span> <br />position: relative;
<div id="div2">
<br /><span class="bold">DIV #2</span> <br />position: absolute;
<br />z-index: 1;
</div>
</div>
<br />
<div id="div3">
<br /><span class="bold">DIV #3</span> <br />position: relative;
<div id="div4">
<br /><span class="bold">DIV #4</span> <br />position: absolute;
<br />z-index: 2;
</div>
</div>
CSS
.bold {
font-family: Arial;
font-size: 12px;
font-weight: bold;
}
#div1,
#div3 {
height: 80px;
position: relative;
border: 1px dashed #669966;
background-color: #ccffcc;
padding-left: 5px;
}
#div2 {
opacity: 0.8;
z-index: 1;
position: absolute;
width: 150px;
height: 200px;
top: 20px;
left: 170px;
border: 1px dashed #990000;
background-color: #ffdddd;
text-align: center;
}
#div4 {
opacity: 0.8;
z-index: 2;
position: absolute;
width: 200px;
height: 80px;
top: 65px;
left: 50px;
border: 1px dashed #000099;
background-color: #ddddff;
text-align: left;
padding-left: 10px;
}
ê²°ê³¼
See also
- Stacking without z-index : Default stacking rules
- Stacking and float : How floating elements are handled
- Adding z-index : Using z-index to change default stacking
- The stacking context : Notes on the stacking context
- Stacking context example 2 : 2-level HTML hierarchy, z-index on all levels
- Stacking context example 3 : 3-level HTML hierarchy, z-index on the second level
Original Document Information
- Author(s): Paolo Lombardi
- This article is the english translation of an article I wrote in italian for YappY. I grant the right to share all the content under Creative Commons: Attribution-Sharealike license
- Last Updated Date: July 9th, 2005