관리 메뉴

Outputor

CSS nth-child μ…€λ ‰ν„° λ³Έλ¬Έ

🎨 CSS πŸ”»

CSS nth-child μ…€λ ‰ν„°

output7 2021. 12. 31. 12:41

 

CSS nth-child 간단 정리

  • :nth-child(n) ➑ μ›ν•˜λŠ” n번째 μš”μ†Œλ§Œ μŠ€νƒ€μΌμ„ 쀄 수 있음
  • :nth-child(even) ➑ 짝수
  • :nth-child(odd) ➑ ν™€μˆ˜
  • :nth-child(3n + 0)   βž‘ 3의 배수

 

 
 
 
 
 
 

 

      .box {
        width: 100px;
        height: 100px;
        background: #fff;
        border: 1px solid #000;
      }
	  .box:nth-child(1) {
        background-color: #1971c2;
      }
      .box:nth-child(even) {
        background-color: #e64980;
      }

 

    <div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
    </div>

'🎨 CSS πŸ”»' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

폰트 Anti-aliasing  (0) 2021.12.31
Pseudo-class μ…€λ ‰ν„°  (0) 2021.12.31
CSS input 정리  (0) 2021.12.31
인라인블둝(inline-block) margin 제거  (0) 2021.12.29
::before ::after κ°€μƒν΄λž˜μŠ€  (0) 2021.12.29