Issue
In CSS is it possible to select all elements before an element with a given class?
Example HTML:
<div>
<a href>One</a>
<a href>Two</a>
<a href>Three</a>
<a href class="active">Four</a>
<a href>Five</a>
</div>
And CSS:
.active:(all-before) {
border-left: solid 1px #C0FFEE;
}
So links 'One', 'Two', and 'Three' would would have a left border but 'Four' and 'Five' would not.
Solution
a {
text-decoration: none;
border-left: 1px solid black;
}
a.active, a.active ~ * {
border: none;
}
<div>
<a href>One</a>
<a href>Two</a>
<a href>Three</a>
<a href class="active">Four</a>
<a href>Five</a>
</div>
Answered By - Chris Burton
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.