z-indexê° ìë ê²½ì°ì ìì
ë§ì½ 모ë ì리먼í¸ë¤ì z-indexê° ì§ì ëì§ ììì ê²½ì°ìë ì리먼í¸ë¤ì´ ë¤ì ììë¡ ìëììë¶í° ìë¡ ìì¸ë¤.
- ë¿ë¦¬ ì리먼í¸ì 배경과 í ë리
- ìì ì리먼í¸ë¤ì HTMLìì ë±ì¥íë ììëë¡
- positionì´ ì§ì ë ìì ì리먼í¸ë¤ì HTMLìì ë±ì¥íë ììëë¡
ë¤ì ìì ìë ìì ìì ê·ì¹ì ì¤ëª í기 ìí ì ë¹í í¬ê¸°ì ì리먼í¸ë¤ì´ ì¤ë¹ëì´ìë¤.
ì°¸ê³ : ë ¸í¸:
- 주ì´ì§ ëì¼í ì리먼í¸ë¤ì 그룹ì 모ë z-indexê° ì¤ì ëì§ ììë¤. DIV #1 ë¶í° DIV #4 ê¹ì§ë position ìì±ì´ ì¤ì ëìë¤. ì리먼í¸ì positionìì± ê°ê³¼ë ìê´ ìì´ HTML ê³ì¸µ 구조ëë¡ ììì ì ì ìë¤.
- position ìì±ì´ ì§ì ëì§ ìì ë¸ë¡(DIV #5)ì íì positionì´ ì§ì ë ìë¦¬ë¨¼í¸ ì´ì ì ë ëë§ ëë¤. ë°ë¼ì positionì´ ì§ì ë ìë¦¬ë¨¼í¸ ìëì ë³´ì¸ë¤. ì¤ë ¹ HTML 문ìììì 먼ì ëì¤ëë¼ë positionì´ ì§ì ëì§ ìì ì리먼í¸ë ì§ì ë ì리먼í¸ë³´ë¤ ìëì ë³´ì¸ë¤.
ìì
>HTML
html
<div id="abs1" class="absolute">
<strong>DIV #1</strong><br />position: absolute;
</div>
<div id="rel1" class="relative">
<strong>DIV #2</strong><br />position: relative;
</div>
<div id="rel2" class="relative">
<strong>DIV #3</strong><br />position: relative;
</div>
<div id="abs2" class="absolute">
<strong>DIV #4</strong><br />position: absolute;
</div>
<div id="sta1" class="static">
<strong>DIV #5</strong><br />position: static;
</div>
CSS
css
strong {
font-family: sans-serif;
}
div {
padding: 10px;
border: 1px dashed;
text-align: center;
}
.static {
position: static;
height: 80px;
background-color: #ffc;
border-color: #996;
}
.absolute {
position: absolute;
width: 150px;
height: 350px;
background-color: #fdd;
border-color: #900;
opacity: 0.7;
}
.relative {
position: relative;
height: 80px;
background-color: #cfc;
border-color: #696;
opacity: 0.7;
}
#abs1 {
top: 10px;
left: 10px;
}
#rel1 {
top: 30px;
margin: 0px 50px 0px 50px;
}
#rel2 {
top: 15px;
left: 20px;
margin: 0px 50px 0px 50px;
}
#abs2 {
top: 10px;
right: 10px;
}
#sta1 {
background-color: #ffc;
margin: 0px 50px 0px 50px;
}
ê²°ê³¼
See also
- 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 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