In my code, I have a structure such as:
<div class=block1">
..
</div>
<div class="block2">
</div>
These two blocks can be changed at the user's will through a page builder.
Now, it just so happens that block1 has some special CSS properties on its own that shouldn't exist when it has another special block (block2 in our case) next / before it.
block1 properties:
border-bottom: 1px solid black;
padding-bottom: 30px;
..
..
block2 properties:
margin-top: 30px;
border-top: 2px solid;
So you can see there are clashing properties and they'd look quite bad. My goal is to remove the properties from block1 and not block2. (I know I can remove from block2, but this is a perfect case where I can remove from block2 to make it work, but it's rarely this easy.)
Here's a visualisation:
This code allows me to tell if block2 comes after block1, like this:
.block1 + .block2 {
//If block2 is after, do some changes to block2
}
I'd want to affect .block1 instead, something like:
if(.block1 + .block2) -> .block1 {
border-bottom: 0; //remove the border bottom so it doesn't look bugged.
padding-bottom: 0; //cut the paddig since it's not necessary.
}
I couldn't find any solution to this except JS, I'm trying to come up with something written in CSS.