π λͺ©μ°¨
- Introduction
- μΌμΉ μ νμ
- μμ μ νμ
- νμ μ νμ
- μΈμ νμ μ νμ
- μΌλ° νμ μ νμ
- Conclusion
π Introduction
π μΌμΉ μ νμ
λͺ¨λ λ§μ‘±νλ μ νμ (λμμ°κΈ°κ° μλ€λ κ²μ μ μ!π¨)
span.orange{
color: red;
}
<div>
<ul>
<li>apple</li>
<li>pear</li>
<li class="orange">orange</li>
</ul>
<div>carrot</div>
<p>tomato</p>
<span class="orange">orange</span> <!-- μ ν -->
</div>
μ¬κΈ°μ spanκ³Ό class="orange"μ ν΄λΉ νλ κ²λ§ color: redλ‘ νμκ° λ©λλ€.
π μμ μ νμ
μ΄λ€ κ²μ μμλ§ μ ννλ μ νμμ λλ€.
ul > .orange{
color: red;
}
<div>
<ul>
<li>apple</li>
<li>pear</li>
<li class="orange">orange</li> <!-- μ ν -->
</ul>
<div>carrot</div>
<p>tomato</p>
<span class="orange">orange</span>
</div>
ulμ μμμ€ orange classμΈκ²λ§ μ ννκ² λ©λλ€.
π νμ μ νμ
νμ μ νμλ νμ μ νμλΌκ³ λ λΆλ¦½λλ€. μΌμΉ μ νμμ λΉμ·νκ² λ³΄μ΄μ§λ§ λμ΄μ°κΈ°κ° λ€μ΄κ° μμ΅λλ€.
div .orange{
color: red;
}
<div>
<ul>
<li>apple</li>
<li>pear</li>
<li class="orange">orange</li> <!-- μ ν -->
</ul>
<div>carrot</div>
<p>tomato</p>
<span class="orange">orange</span> <!-- μ ν -->
</div>
μ΄λ κ² div μλμ νμ μμμ€ orange ν΄λμ€λ₯Ό κ°μ§κ³ μλ κ²λ€μ μ ννκ² λ©λλ€.
π μΈμ νμ μ νμ
μΈμ νμ μ νμλ +λ₯Ό μ¬μ©ν©λλ€. μ²μ μμμ λ€μ νλμ νμ μμλ§ μ νν©λλ€.
.orange + li{
color: red;
}
<div>
<ul>
<li>apple</li>
<li>pear</li>
<li class="orange">orange</li>
<li>mango</li> <!-- μ ν -->
</ul>
<div>carrot</div>
<p>tomato</p>
<span class="orange">orange</span>
</div>
π μΌλ° νμ μ νμ
μΌλ° νμ μ νμλ ~λ₯Ό μ¬μ©νκ² λ©λλ€. μΈμ νμ μ νμμ λ¬λ¦¬ μ²μ μμμ λ€μ λͺ¨λ νμ μμλ₯Ό μ νν©λλ€.
.orange ~ li{
color: red;
}
<div>
<ul>
<li>apple</li>
<li>pear</li>
<li class="orange">orange</li>
<li>mango</li> <!-- μ ν -->
<li>straberry</li> <!-- μ ν -->
<li>banana</li> <!-- μ ν -->
</ul>
<div>carrot</div>
<p>tomato</p>
<span class="orange">orange</span>
</div>
π Conclusion
'CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
CSS - κ°μν΄λμ€ + μμ μ νμ (0) | 2021.01.28 |
---|