civiltomain
civiltomain

Reputation: 1166

How to select a particular div at my own level

I have :

<div class=mystyle>
    <input type=checkbox>
    <div>
      <div>
        <div>
         .....
        </div>
       </div>
     </div>

    <div>// this is what I want 
    </div>


</div>

I want to create a css style to be applied to the last div at the same level of element or also can be the second div ...

I think I could use [attribute] approach but... Is there any way to use another selector ? It is possible I could have more than one input-div-div structure inside mystyle input:checked ?

Upvotes: 0

Views: 78

Answers (1)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123367

you may use

input ~ div:last-of-type {
   color: green;
}

this selector will pick the last sibling div of your input

example: http://codepen.io/anon/pen/pvwEoB

Upvotes: 1

Related Questions