Reputation: 981
How to style element after element? For example i have this:
<ul>
<li>A</li>
<li class="hiden">B</li>
<li>C</li>
<li>D</li>
<li class="hiden">E</li>
<li class="hiden">E</li>
<li class="hiden">E</li>
<li>F</li>
</ul>
I want every first li after li.hiden to have border-top.
li + li.hiden works only on first element in ul.
Upvotes: 2
Views: 84
Reputation: 677
What about CSS3 selector? Try this:
:nth-child(2n)
You'll find more information here.
Upvotes: 0
Reputation: 1406
This will help you..
https://jsfiddle.net/0c5eu92w/
li.hiden + li{border-top:1px solid #ccc;}
Upvotes: 0
Reputation: 193261
To target first li
after li.hiden
you should use li.hiden + li
selector:
li.hiden + li {
border-top: 1px red solid;
}
<ul>
<li>A</li>
<li class="hiden">B</li>
<li>C</li>
<li>D</li>
<li class="hiden">E</li>
<li>F</li>
</ul>
Upvotes: 4