z-index μμ±μ κ²ΉμΉλ μμμ μμ μμλ₯Ό μ μ΄ ν©λλ€.
z-index λ position μ absolute
, relative
, fixed
μΌ λλ§ λμνλ©° μμλ₯Ό μ¬μ©ν μ μμ΅λλ€.
μ¦, position: static
μ΄ μλ κ°μ κ°λ μμμλ§ μν₯μ μ€λλ€.
z-index κ·μΉ
- position μμ±μ΄ μλ νκ·Έλ€μ λμ€λ μμλλ‘ μμ λλ€.
- position μμ±μ΄ μλ νκ·Έλ€μ μλ νκ·Έλ€λ³΄λ€ μμ λμ€λ μμλλ‘ μμ λλ€.
- position μμ±μ z-indexκΉμ§ μλ€λ©΄ z-indexκ° ν° νκ·Έκ° μμ μμ λλ€.
- z-indexμ΄ κ°μ κ°μΌ κ²½μ° HTML ꡬ쑰μ μλμΈ κ²μ΄ λ¨Όμ μ μ© λ©λλ€.
- z-indexκ° μ무리 ν¬λλΌλ λΆλͺ¨ νκ·Έμ z-indexκ° λ μ°μ μ λλ€.
z-index μ’ λ₯
z-index : auto | number
- auto : λ¬Έμ νλ¦μ λ°λ₯Έ κΈ°λ³Έ μμΉμ μμΉ (κΈ°λ³Έκ°)
- number : μ«μ ν΄μλ‘ κ²Ήμ³€μ λ μμ μμΉνκ³ , μμκ° λ κ²½μ° μλμ μμΉ
z-index μμ
<div class="container">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</div>
.container{
width: 500px;
height: 500px;
position: relative;
background-color: silver;
}
div {
width: 100px;
height: 100px;
}
.box1 {
background-color: red;
position: absolute;
top: 50px;
left: 80px;
z-index: 3;
}
.box2 {
background-color: orange;
position: absolute;
top: 70px;
left: 100px;
z-index: 3;
}
.box3 {
background-color: blue;
position: absolute;
top: 90px;
left: 120px;
z-index: 2;
}
.box4{
background-color: hotpink;
position: absolute;
top: 120px;
left: 150px;
z-index: 4;
}
μ°Έκ³
- https://homzzang.com/b/css-113
- https://be-a-weapon.tistory.com/112
- https://www.zerocho.com/category/CSS/post/5a18b330e9c0ec001b08238e
- https://developer.mozilla.org/ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
- https://developer.mozilla.org/ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index
'π Front-End > CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
Resettingκ³Ό Normalizing CSS (0) | 2022.10.20 |
---|---|
CSS μ°μ μμ (0) | 2022.10.20 |
em & rem (0) | 2022.10.20 |
Flex (0) | 2022.10.20 |
Grid (0) | 2022.10.20 |