This one is puzzling me because it seems so simple and yet I can't solve the problem.
To give a bit of context, I'm preparing a little HTML application that generates a list of divs based on the filters chosen by the end user. The end user can then manually remove elements he's not interested to, basically by adding the class "hidden" to them via JavaScript.
The problem is, some of these elements have a bigger border and when they become adjacent on the screen the border becomes even thicker, and thus uglier. I managed to solve all other problems, but now when I have a situation similar to this, I can't find the correct CSS selector:
<div>...</div>
<div>...</div>
<div class="bigborders">...</div>
<div class="hidden">...</div>
<div class="hidden">...</div>
<div class="hidden">...</div>
<div class="bigborders">...</div>
<div>...</div>
<div class="bigborders">...</div>
<div>...</div>
<div>...</div>
And for the sake of it, let's add some CSS rules, simplified to the bone:
.hidden {
display: none;
}
.bigborders {
border-top: 2px solid #AAAAAA;
border-bottom: 2px solid #AAAAAA;
}
https://jsfiddle.net/3tzrsq1d/1/
I'd like to select only the first .bigborders
after another .bigborders
, ignoring all the hidden divs in between, to remove its upper border, but the only selectors for siblings are +
, that selects the element immediately following (but that's true only on the screen, not in the code), and ~
, that selects every following element (but I need only the first one, not every one). I also experimented with :first-of-type
and nth-of-type
, but this pseudo-class works with respect to the parent element of the first .bigborders
, not that element itself.
Is there another way that I can't see?