728x90
λ°μν
π λμΌν z-indexμΌ λ μλ‘ νμλλ μμ μμ
- HTMLμμ λμ€μ μ μΈλ μμκ° μλ‘ νμλ¨
- DOM(Document Object Model) ꡬ쑰μμ λ€μͺ½(later in the DOM)μ μλ μμκ° μμ νμλ©λλ€.
<div class="box" style="z-index: 10; position: absolute;">Box 1</div>
<div class="box" style="z-index: 10; position: absolute;">Box 2</div>
2. μμμ λΆλͺ¨(stacking context)κ° λμ z-indexλ₯Ό κ°μ§λ©΄ κ·Έ μμ μμλ μν₯μ λ°μ
- λΆλͺ¨ μμμ z-indexκ° λμ μμ μμ μμ μμλ, z-indexκ° κ°λλΌλ λ€λ₯Έ λΆλͺ¨ μλμ μλ μμλ³΄λ€ μμ μ¬ μ μμ.
<div style="position: relative; z-index: 5;">
<div style="position: absolute; z-index: 10;">A</div>
</div>
<div style="position: relative; z-index: 3;">
<div style="position: absolute; z-index: 10;">B</div>
</div>
3. position: relative | absolute | fixed | stickyκ° μ μ©λ μμκ° position: staticμΈ μμλ³΄λ€ μμ νμλ¨
- positionμ΄ μ€μ λμ§ μμ(static) μμλ positionμ΄ μλ μμλ³΄λ€ λ€λ‘ κ°.
<div style="z-index: 10;">Static Element</div>
<div style="position: absolute; z-index: 10;">Absolute Element</div>
π― κ²°λ‘
β κ°μ z-indexλΌλ©΄?
- HTMLμμ λμ€μ λ±μ₯ν μμκ° μμ νμλ¨
- λΆλͺ¨ μμμ z-indexκ° λμ κ²½μ°, κ·Έ μμλ μν₯μ λ°μ
- position: relative | absolute | fixed μμκ° static μμλ³΄λ€ μμ νμλ¨
- νμνλ©΄ z-indexλ₯Ό λ λμ΄κ±°λ, DOM μμλ₯Ό λ³κ²½νλ©΄ ν΄κ²° κ°λ₯! π
728x90
λ°μν
'Front > CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[CSS] remλ¨μ (0) | 2024.08.06 |
---|---|
[CSS] visibility : μμλ₯Ό μ¨κΈ°κ³ 곡κ°μ κ·Έλλ‘ μ μ§νκΈ° (0) | 2024.07.20 |
[CSS] table header μλ¨μ κ³ μ μν€κΈ° (0) | 2024.06.20 |
[CSS] border-collapse (0) | 2024.06.19 |
[CSS][Bootstrap] multiselect μμΉ μ‘°μ νκΈ° (0) | 2024.05.11 |