Van
Van

Reputation: 23

How select only all first child of another div

Suppose to have this html code:

<div class="colora_riga">
     <!--only this div-->
     <div>
         <div>...</div>
     </div>
     <!--only this div-->
     <div>
        <div>...</div>
     </div>
</div>

I want take the all only first child directly of div with colora_riga like class. I dont' want the div another div. This is my css:

.colora_riga > div:first-child {
    border:1px ridge #999999;  
}

This rule works only for the first child of div with "colora-riga" like class, for the second directly child the rule is not applied. Anyone can help me?

Upvotes: 1

Views: 81

Answers (1)

Zenoo
Zenoo

Reputation: 12880

If I understood you correctly, you want every div directly under .colora_riga, you don't need :first-child then :

.colora_riga > div {
    border:1px ridge #999999;  
}

Upvotes: 3

Related Questions