css - How do I target only elements that are followed by another (specific) element? -


i have code generated drupal view. looks (stripped down clarity):

<div class="group_content">   <h3>header link</h3>   <div class="row odd">here's content</div>   <h3>another header link</h3>   <div class="row even">here's more content</div> </div>  <div class="group_content">   <h3>header link 2</h3>   <div class="row odd">here's content 2</div> </div> 

because generated cms, there's limit can rendered code - example, can't add even/odd class h3 elements.

how can (in css) target div class=row followed div class=row? if there more 1 row in group, need add bottom border div act visual separator. so, using example code, there border applied div class="row odd">here's content</div> because has row following it.

i'm backend developer, css not strong suit. need support ie7.

modified logic

since need ie7 support, place border on h3 element instead:

div.row + h3 {     border-top: 1px solid black; } 

this work in every modern browser, , ie7:

fiddle: http://jsfiddle.net/jonathansampson/bjuf9/1/

explicit subjects in selectors

if insist on placing on every div.row last, that's different story. you're asking moving subject of selector, not possible, when browsers implement level 4 selectors:

div.row! + div.row {     /* these styles apply first div.row        $div.row + div.row potential         syntax */ } 

:last-child, in ie9+

since cannot that, can set style div.row elements, adding border, , overriding div.row:last-child remove border div.row last element in parent:

div.row {     border-bottom: 1px solid #333; } div.row:last-child {     border-bottom: 0px; } 

fiddle: http://jsfiddle.net/jonathansampson/bjuf9/

i should note not work in ie7, unfortunately. modified logic presented in first solution should take care of there.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -