+ Reply to Thread
Results 1 to 3 of 3

Thread: Select an alternative divs

  1. #1

    Select an alternative divs

    HTML :
    Code:
    <div class="right_col">
    
       <div class="right_box">
          <div class="other_div">text</div>
          text etc
       </div>
    
       <div class="right_box">
          <div class="other_div">text</div>
          text etc
       </div>
    
    
       <div class="right_box">
          <div class="other_div">text</div>
          <div class="anotherother_div">text</div>
          text etc
       </div>
    
       <div class="right_box">
          text etc
       </div>
    
    </div>
    So a main div with other divs inside which may or may not contain additional divs. What I want to do is style them so "right_box" has alternate background colours. The problem is that I am selecting the interior divs/taking them into account when doing odd/even etc.

    CSS :
    Code:
    .right_col .right_col:nth-child(even) {background:red}
    .right_col .right_col:nth-child(0n+1) {background:red}
    Any idea what is wrong ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    19
    Use nth-of-type() instead of nth-child and that is it , glad that i helped

  3. #3
    oh , thank you very much , i always do these small mistakes . but i am learning .

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts