CSSμ z-index
μμ±μ μμμ μμ μμ(μ€ν μμ)λ₯Ό μ§μ νλ λ° μ¬μ©λ©λλ€. HTML λ¬Έμμμ μ¬λ¬ μμκ° κ²Ήμ³μμ λ, z-index
λ₯Ό μ΄μ©νμ¬ μ΄λ€ μμκ° λ€λ₯Έ μμ μμ λνλ μ§ κ²°μ ν μ μμ΅λλ€.
z-index
μ κ°μ μ μμ΄λ©°, λ ν° κ°μ΄ λμ μμ μμλ₯Ό λνλ
λλ€. μμ κ°λ μ¬μ©ν μ μμ΅λλ€. μΌλ°μ μΌλ‘ z-index
λ μλμ λλ μ λμ μΌλ‘ μμΉκ° μ§μ λ μμμλ§ μ μ©λλ©°, κΈ°λ³Έμ μΌλ‘ λͺ¨λ μμμ z-index
κ°μ 'auto'λ‘ μ€μ λμ΄ μμ΅λλ€.
κ°λ¨ν μμ λ₯Ό ν΅ν΄ μ€λͺ νκ² μ΅λλ€:
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.box1 {
position: relative;
background-color: #ffcc00;
width: 150px;
height: 150px;
z-index: 2;
}
.box2 {
position: relative;
background-color: #66ccff;
width: 150px;
height: 150px;
top: -50px; /* μλμ μΈ μμΉ μ‘°μ */
left: 50px;
z-index: 1;
}
</style>
</head>
<body>
<div class="box1">Box 1</div>
<div class="box2">Box 2</div>
</body>
</html>
μ΄ μμ μμ box1
κ³Ό box2
λ κ²Ήμ³ μμ΅λλ€. z-index
κ°μ΄ λμ box1
μ box2
μμ λνλ©λλ€. λ§μ½ z-index
κ° κ°λ€λ©΄, HTML λ¬Έμμμ λμ€μ λνλλ μμκ° μμ λνλ©λλ€.