ìì ë§¥ë½ ìì 2
êµì¥í ê°ë¨íì§ë§ ìì ë§¥ë½ì ì´í´íëë° ëìì´ ëë ìì 를 íë ìê°íë ¤ íë¤. ì´ì ìì ìì 본 4ê°ì DIVê° ìë¤. ì´ë²ìë ë ë 벨ì DIV 모ë z-index ìì± ê°ì ì§ì íë¤.
z-index ìì± ê°ì´ 2ì¸ DIV #2ë z-index ìì± ê°ì´ 1ì¸ DIV #3 ìì ìë¤. ìëíë©´ DIV #2ì DIV #3ì ê°ì ìì ë§¥ë½(ë£¨í¸ ì리먼í¸)ì ìíê³ DIV #2ì z-index ê°ì´ ë í¬ê¸° ë문ì´ë¤.
ì´ìí ì ì z-index ìì± ê°ì´ 2ì¸ DIV #2ê° z-index ìì± ê°ì´ 10ì¸ DIV #4ë³´ë¤ ìì ìë¤ë ì ì´ë¤. ì´ê²ì ì´ ë DIVê° ê°ì ìì ë§¥ë½ì ìí´ìì§ ì기 ë문ì´ë¤. DIV #4ë DIV #3ì´ ë§ë ìì ë§¥ë½ì ìí´ìê³ DIV #3ê³¼ DIV #3ì 모ë ìì ì리먼í¸ë DIV #2ë³´ë¤ ìëì ìë¤.
ì´ ìí©ì ë ì ì´í´í기 ìí´ì ìì ë§¥ë½ ê³ì¸µì ê·¸ë ¤ë³´ì.
- ë£¨í¸ ìë¦¬ë¨¼í¸ ìì ë§¥ë½
- DIV #2 (z-index 2)
- DIV #3 (z-index 1)
- DIV #4 (z-index 10)
ì°¸ê³ : ì¼ë°ì ì¸ HTML ê³ì¸µ êµ¬ì¡°ê° ìì ë§¥ë½ ê³ì¸µ 구조ì ë¤ë¥´ë¤ë걸 ì기íì. ìì ë§¥ë½ì ë§ë¤ì§ ìë ì리먼í¸ë¤ì ìì ë§¥ë½ ê³ì¸µ 구조ìì ì¬ë¼ì§ë¤.
ìì
>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: 2;
</div>
</div>
<br />
<div id="div3">
<br />
<span class="bold">DIV #3</span><br />
position: relative;<br />
z-index: 1;
<div id="div4">
<br />
<span class="bold">DIV #4</span><br />
position: absolute;<br />
z-index: 10;
</div>
</div>
CSS
div {
font: 12px Arial;
}
span.bold {
font-weight: bold;
}
#div2 {
z-index: 2;
}
#div3 {
z-index: 1;
}
#div4 {
z-index: 10;
}
#div1,
#div3 {
height: 80px;
position: relative;
border: 1px dashed #669966;
background-color: #ccffcc;
padding-left: 5px;
}
#div2 {
opacity: 0.8;
position: absolute;
width: 150px;
height: 200px;
top: 20px;
left: 170px;
border: 1px dashed #990000;
background-color: #ffdddd;
text-align: center;
}
#div4 {
opacity: 0.8;
position: absolute;
width: 200px;
height: 70px;
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 1 : 2-level HTML hierarchy, z-index on the last level
- 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