View

[CSS] CSS μ„ νƒμž

μ±…μ½λŠ” 감자 2022. 9. 17. 16:00
λ°˜μ‘ν˜•

πŸ’‘κΈ°λ³Έ μ„ νƒμž

전체 μ„ νƒμž
λͺ¨λ“  μš”μ†Œλ₯Ό μ„ νƒν•©λ‹ˆλ‹€. μΆ”κ°€λ‘œ λ„€μž„μŠ€νŽ˜μ΄μŠ€ μ œν•œμ„ λ‘˜ 수 μžˆμŠ΅λ‹ˆλ‹€. 
* {
  color: green;
}

 

μœ ν˜• μ„ νƒμž
λ…Έλ“œ 이름을 μ‚¬μš©ν•΄ μš”μ†Œλ₯Ό μ„ νƒν•©λ‹ˆλ‹€. 즉 λ¬Έμ„œ λ‚΄μ—μ„œ 주어진 μœ ν˜•μ˜ λͺ¨λ“  μš”μ†Œλ₯Ό μ„ νƒν•©λ‹ˆλ‹€.
a {
  color: red;
}

 

클래슀 μ„ νƒμž
μš”μ†Œμ˜ class νŠΉμ„±μ— κΈ°λ°˜ν•΄ μš”μ†Œλ₯Ό μ„ νƒν•©λ‹ˆλ‹€.
.red {
  color: #f33;
}

.yellow-bg {
  background: #ffa;
}
<p class="red">λΉ¨κ°„ κΈ€μžμƒ‰μ˜ λ¬Έλ‹¨μž…λ‹ˆλ‹€.</p>
<p class="red yellow-bg">λΉ¨κ°„ κΈ€μžμƒ‰κ³Ό λ…Έλž€ 배경의 λ¬Έλ‹¨μž…λ‹ˆλ‹€.</p>

 

ID μ„ νƒμž 
μš”μ†Œμ˜ id νŠΉμ„± 값을 λΉ„κ΅ν•˜μ—¬, μ™„μ „νžˆ λ™μΌν•œ idλ₯Ό 가진 μš”μ†Œλ₯Ό μ„ νƒν•©λ‹ˆλ‹€.
#identified {
  background-color: skyblue;
}
<div id="identified">νŠΉλ³„ν•œ IDλ₯Ό 가진 μš”μ†Œμ—μš”!</div>
<div>이건 κ·Έλƒ₯ divμ—μš”.</div>

 

 

πŸ’‘ κ·Έλ£Ή μ„ νƒμž 

μ—¬λŸ¬ 쀄 λ¬ΆκΈ°

#main,
.content,
article {
  font-size: 1.1em;
}

ν•œμ€„λ‘œ λ¬ΆκΈ°

h1, h2, h3, h4, h5, h6 { font-family: helvetica; }

 

πŸ’‘ κ²°ν•©μž

μžμ† κ²°ν•©μž
보톡 ν•œ 칸의 곡백 문자둜 ν‘œν˜„ν•˜λŠ” μžμ† κ²°ν•©μž(" ")λŠ” 두 개의 μ„ νƒμžλ₯Ό μ‘°ν•©ν•˜μ—¬, λ’€μͺ½ μ„ νƒμž μš”μ†Œμ˜ 쑰상(λΆ€λͺ¨, λΆ€λͺ¨μ˜ λΆ€λͺ¨, λΆ€λͺ¨μ˜ λΆ€λͺ¨μ˜ λΆ€λͺ¨...)에 μ•žμͺ½ μ„ νƒμž μš”μ†Œκ°€ μ‘΄μž¬ν•  경우 μ„ νƒν•©λ‹ˆλ‹€. 

CSS

li {
  list-style-type: disc;
}

li li {
  list-style-type: circle;
}
Copy to Clipboard

HTML

<ul>
  <li>
    <div>Item 1</div>
    <ul>
      <li>Subitem A</li>
      <li>Subitem B</li>
    </ul>
  </li>
  <li>
    <div>Item 2</div>
    <ul>
      <li>Subitem A</li>
      <li>Subitem B</li>
    </ul>
  </li>
</ul>
Copy to Clipboard

 

 

 

μžμ† κ²°ν•©μž

μžμ‹ κ²°ν•©μž(>)λŠ” 두 개의 CSS μ„ νƒμž 사이에 μœ„μΉ˜ν•˜μ—¬ λ’€μͺ½ μ„ νƒμžμ˜ μš”μ†Œκ°€ μ•žμͺ½ μ„ νƒμž μš”μ†Œμ˜ λ°”λ‘œ 밑에 μœ„μΉ˜ν•  κ²½μš°μ—λ§Œ μ„ νƒν•©λ‹ˆλ‹€.

CSS

span {
  background-color: white;
}

div > span {
  background-color: DodgerBlue;
}
Copy to Clipboard

HTML

<div>
  <span>Span #1, in the div.
    <span>Span #2, in the span that's in the div.</span>
  </span>
</div>
<span>Span #3, not in the div at all.</span>
 
λ‚˜λ¨Έμ§€ κ²°ν•©μž

 

 


좜처: https://developer.mozilla.org/ko/docs/Web/CSS/CSS_Selectors

λ°˜μ‘ν˜•

'Web > CSS' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[CSS] display속성  (0) 2022.09.18
[CSS] Position 속성  (0) 2022.09.17
Share Link
reply
λ°˜μ‘ν˜•
Β«   2024/11   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30